mirror of
https://github.com/Xaymar/obs-StreamFX
synced 2024-11-24 04:15:11 +00:00
utility: Add any and exact matching for enum class bitmasks
This commit is contained in:
parent
cbada3e438
commit
e5fb68d2c1
1 changed files with 14 additions and 0 deletions
|
@ -48,6 +48,20 @@ typename std::enable_if<enable_bitmask_operators<Enum>::enable, Enum>::type oper
|
|||
return static_cast<Enum>(static_cast<underlying>(lhs) & static_cast<underlying>(rhs));
|
||||
}
|
||||
|
||||
template<typename Enum>
|
||||
typename std::enable_if<enable_bitmask_operators<Enum>::enable, bool>::type any(Enum lhs)
|
||||
{
|
||||
using underlying = typename std::underlying_type<Enum>::type;
|
||||
return static_cast<underlying>(lhs) != static_cast<underlying>(0);
|
||||
}
|
||||
|
||||
template<typename Enum>
|
||||
typename std::enable_if<enable_bitmask_operators<Enum>::enable, bool>::type exact(Enum lhs, Enum rhs)
|
||||
{
|
||||
using underlying = typename std::underlying_type<Enum>::type;
|
||||
return static_cast<underlying>(lhs) == static_cast<underlying>(rhs);
|
||||
}
|
||||
|
||||
#define P_ENABLE_BITMASK_OPERATORS(x) \
|
||||
template<> \
|
||||
struct enable_bitmask_operators<x> { \
|
||||
|
|
Loading…
Reference in a new issue