aboutsummaryrefslogtreecommitdiffstats
path: root/al/eax/utils.h
diff options
context:
space:
mode:
Diffstat (limited to 'al/eax/utils.h')
-rw-r--r--al/eax/utils.h69
1 files changed, 15 insertions, 54 deletions
diff --git a/al/eax/utils.h b/al/eax/utils.h
index d3d4a196..5a8fdd64 100644
--- a/al/eax/utils.h
+++ b/al/eax/utils.h
@@ -6,22 +6,14 @@
#include <string>
#include <type_traits>
-
-struct EaxAlLowPassParam
-{
+struct EaxAlLowPassParam {
float gain;
float gain_hf;
-}; // EaxAlLowPassParam
-
+};
-void eax_log_exception(
- const char* message = nullptr) noexcept;
+void eax_log_exception(const char* message = nullptr) noexcept;
-
-template<
- typename TException,
- typename TValue
->
+template<typename TException, typename TValue>
void eax_validate_range(
const char* value_name,
const TValue& value,
@@ -29,9 +21,7 @@ void eax_validate_range(
const TValue& max_value)
{
if (value >= min_value && value <= max_value)
- {
return;
- }
const auto message =
std::string{value_name} +
@@ -43,60 +33,38 @@ void eax_validate_range(
throw TException{message.c_str()};
}
+namespace detail {
-namespace detail
-{
-
-
-template<
- typename T
->
-struct EaxIsBitFieldStruct
-{
+template<typename T>
+struct EaxIsBitFieldStruct {
private:
using yes = std::true_type;
using no = std::false_type;
- template<
- typename U
- >
+ template<typename U>
static auto test(int) -> decltype(std::declval<typename U::EaxIsBitFieldStruct>(), yes{});
- template<
- typename
- >
+ template<typename>
static no test(...);
-
public:
static constexpr auto value = std::is_same<decltype(test<T>(0)), yes>::value;
-}; // EaxIsBitFieldStruct
-
+};
-template<
- typename T,
- typename TValue
->
-inline bool eax_bit_fields_are_equal(
- const T& lhs,
- const T& rhs) noexcept
+template<typename T, typename TValue>
+inline bool eax_bit_fields_are_equal(const T& lhs, const T& rhs) noexcept
{
static_assert(sizeof(T) == sizeof(TValue), "Invalid type size.");
-
return reinterpret_cast<const TValue&>(lhs) == reinterpret_cast<const TValue&>(rhs);
}
-
} // namespace detail
-
template<
typename T,
std::enable_if_t<detail::EaxIsBitFieldStruct<T>::value, int> = 0
>
-inline bool operator==(
- const T& lhs,
- const T& rhs) noexcept
+inline bool operator==(const T& lhs, const T& rhs) noexcept
{
using Value = std::conditional_t<
sizeof(T) == 1,
@@ -107,13 +75,9 @@ inline bool operator==(
std::conditional_t<
sizeof(T) == 4,
std::uint32_t,
- void
- >
- >
- >;
+ void>>>;
static_assert(!std::is_same<Value, void>::value, "Unsupported type.");
-
return detail::eax_bit_fields_are_equal<T, Value>(lhs, rhs);
}
@@ -121,12 +85,9 @@ template<
typename T,
std::enable_if_t<detail::EaxIsBitFieldStruct<T>::value, int> = 0
>
-inline bool operator!=(
- const T& lhs,
- const T& rhs) noexcept
+inline bool operator!=(const T& lhs, const T& rhs) noexcept
{
return !(lhs == rhs);
}
-
#endif // !EAX_UTILS_INCLUDED