1 #ifndef EAX_UTILS_INCLUDED
2 #define EAX_UTILS_INCLUDED
9 using EaxDirtyFlags = unsigned int;
11 struct EaxAlLowPassParam {
16 void eax_log_exception(const char *message) noexcept;
18 template<typename TException, typename TValue>
19 void eax_validate_range(
20 const char* value_name,
22 const TValue& min_value,
23 const TValue& max_value)
25 if (value >= min_value && value <= max_value)
29 std::string{value_name} +
30 " out of range (value: " +
31 std::to_string(value) + "; min: " +
32 std::to_string(min_value) + "; max: " +
33 std::to_string(max_value) + ").";
35 throw TException{message.c_str()};
41 struct EaxIsBitFieldStruct {
43 using yes = std::true_type;
44 using no = std::false_type;
47 static auto test(int) -> decltype(std::declval<typename U::EaxIsBitFieldStruct>(), yes{});
53 static constexpr auto value = std::is_same<decltype(test<T>(0)), yes>::value;
56 template<typename T, typename TValue>
57 inline bool eax_bit_fields_are_equal(const T& lhs, const T& rhs) noexcept
59 static_assert(sizeof(T) == sizeof(TValue), "Invalid type size.");
60 return reinterpret_cast<const TValue&>(lhs) == reinterpret_cast<const TValue&>(rhs);
67 std::enable_if_t<detail::EaxIsBitFieldStruct<T>::value, int> = 0
69 inline bool operator==(const T& lhs, const T& rhs) noexcept
71 using Value = std::conditional_t<
82 static_assert(!std::is_same<Value, void>::value, "Unsupported type.");
83 return detail::eax_bit_fields_are_equal<T, Value>(lhs, rhs);
88 std::enable_if_t<detail::EaxIsBitFieldStruct<T>::value, int> = 0
90 inline bool operator!=(const T& lhs, const T& rhs) noexcept
95 #endif // !EAX_UTILS_INCLUDED