6 #include <system_error>
10 #define LIKELY(x) __builtin_expect(static_cast<bool>(x), true)
11 #define UNLIKELY(x) __builtin_expect(static_cast<bool>(x), false)
13 #define LIKELY(x) static_cast<bool>(x)
14 #define UNLIKELY(x) static_cast<bool>(x)
17 #define DECL_THUNK0(ret, C, Name, cv) \
18 ret C::Name() cv { return pImpl->Name(); }
19 #define DECL_THUNK1(ret, C, Name, cv, T1) \
20 ret C::Name(T1 a) cv \
23 return pImpl->Name(std::forward<_t1>(a)); \
25 #define DECL_THUNK2(ret, C, Name, cv, T1, T2) \
26 ret C::Name(T1 a, T2 b) cv \
28 using _t1 = T1; using _t2 = T2; \
29 return pImpl->Name(std::forward<_t1>(a), std::forward<_t2>(b)); \
31 #define DECL_THUNK3(ret, C, Name, cv, T1, T2, T3) \
32 ret C::Name(T1 a, T2 b, T3 c) cv \
34 using _t1 = T1; using _t2 = T2; using _t3 = T3; \
35 return pImpl->Name(std::forward<_t1>(a), std::forward<_t2>(b), \
36 std::forward<_t3>(c)); \
38 #define DECL_THUNK6(ret, C, Name, cv, T1, T2, T3, T4, T5, T6) \
39 ret C::Name(T1 a, T2 b, T3 c, T4 d, T5 e, T6 f) cv \
41 using _t1 = T1; using _t2 = T2; using _t3 = T3; \
42 using _t4 = T4; using _t5 = T5; using _t6 = T6; \
43 return pImpl->Name(std::forward<_t1>(a), std::forward<_t2>(b), \
44 std::forward<_t3>(c), std::forward<_t4>(d), \
45 std::forward<_t5>(e), std::forward<_t6>(f)); \
52 inline std::future_status
GetFutureState(const SharedFuture
<T
> &future
)
53 { return future
.wait_for(std::chrono::seconds::zero()); }
58 std::array
<uint8_t,(N
+7)/8> mElems
;
61 bool operator[](size_t i
) const { return mElems
[i
/8] & (1<<(i
%8)); }
63 void clear() { std::fill(mElems
.begin(), mElems
.end(), 0); }
64 void set(size_t i
) { mElems
[i
/8] |= 1<<(i
%8); }
68 class alc_category
: public std::error_category
{
69 alc_category() noexcept
{ }
72 static alc_category sSingleton
;
74 const char *name() const noexcept override final
{ return "alc_category"; }
75 std::error_condition
default_error_condition(int code
) const noexcept override final
76 { return std::error_condition(code
, *this); }
78 bool equivalent(int code
, const std::error_condition
&condition
) const noexcept override final
79 { return default_error_condition(code
) == condition
; }
80 bool equivalent(const std::error_code
&code
, int condition
) const noexcept override final
81 { return *this == code
.category() && code
.value() == condition
; }
83 std::string
message(int condition
) const override final
;
86 inline std::system_error
alc_error(int code
, T
&& what
)
87 { return std::system_error(code
, alc_category::sSingleton
, std::forward
<T
>(what
)); }
88 inline std::system_error
alc_error(int code
)
89 { return std::system_error(code
, alc_category::sSingleton
); }
91 class al_category
: public std::error_category
{
92 al_category() noexcept
{ }
95 static al_category sSingleton
;
97 const char *name() const noexcept override final
{ return "al_category"; }
98 std::error_condition
default_error_condition(int code
) const noexcept override final
99 { return std::error_condition(code
, *this); }
101 bool equivalent(int code
, const std::error_condition
&condition
) const noexcept override final
102 { return default_error_condition(code
) == condition
; }
103 bool equivalent(const std::error_code
&code
, int condition
) const noexcept override final
104 { return *this == code
.category() && code
.value() == condition
; }
106 std::string
message(int condition
) const override final
;
109 inline std::system_error
al_error(int code
, T
&& what
)
110 { return std::system_error(code
, al_category::sSingleton
, std::forward
<T
>(what
)); }
111 inline std::system_error
al_error(int code
)
112 { return std::system_error(code
, al_category::sSingleton
); }
116 #endif /* ALURE_MAIN_H */