1 #ifndef EAX_UTILS_INCLUDED
2 #define EAX_UTILS_INCLUDED
10 struct EaxAlLowPassParam
14 }; // EaxAlLowPassParam
17 void eax_log_exception(
18 const char* message
= nullptr) noexcept
;
25 void eax_validate_range(
26 const char* value_name
,
28 const TValue
& min_value
,
29 const TValue
& max_value
)
31 if (value
>= min_value
&& value
<= max_value
)
37 std::string
{value_name
} +
38 " out of range (value: " +
39 std::to_string(value
) + "; min: " +
40 std::to_string(min_value
) + "; max: " +
41 std::to_string(max_value
) + ").";
43 throw TException
{message
.c_str()};
54 struct EaxIsBitFieldStruct
57 using yes
= std::true_type
;
58 using no
= std::false_type
;
63 static auto test(int) -> decltype(std::declval
<typename
U::EaxIsBitFieldStruct
>(), yes
{});
72 static constexpr auto value
= std::is_same
<decltype(test
<T
>(0)), yes
>::value
;
73 }; // EaxIsBitFieldStruct
80 inline bool eax_bit_fields_are_equal(
82 const T
& rhs
) noexcept
84 static_assert(sizeof(T
) == sizeof(TValue
), "Invalid type size.");
86 return reinterpret_cast<const TValue
&>(lhs
) == reinterpret_cast<const TValue
&>(rhs
);
95 std::enable_if_t
<detail::EaxIsBitFieldStruct
<T
>::value
, int> = 0
97 inline bool operator==(
99 const T
& rhs
) noexcept
101 using Value
= std::conditional_t
<
115 static_assert(!std::is_same
<Value
, void>::value
, "Unsupported type.");
117 return detail::eax_bit_fields_are_equal
<T
, Value
>(lhs
, rhs
);
122 std::enable_if_t
<detail::EaxIsBitFieldStruct
<T
>::value
, int> = 0
124 inline bool operator!=(
126 const T
& rhs
) noexcept
128 return !(lhs
== rhs
);
132 #endif // !EAX_UTILS_INCLUDED