mirror of
https://github.com/justinian/jsix.git
synced 2025-12-10 00:14:32 -08:00
[kutil] Add bitfiled::has() for non-marked enums
Added a simple helper function for testing non-marked enum bitfields.
This commit is contained in:
@@ -86,6 +86,16 @@ template <typename E>
|
||||
constexpr typename std::enable_if<is_enum_bitfield(E{}),bool>::type
|
||||
operator && (E rhs, E lhs) { return (rhs & lhs) == lhs; }
|
||||
|
||||
/// Generic 'has' for non-marked bitfields
|
||||
template <typename E, typename F>
|
||||
constexpr bool has(E set, F flags)
|
||||
{
|
||||
return
|
||||
(static_cast<typename integral<E>::type>(set) &
|
||||
static_cast<typename integral<F>::type>(flags)) ==
|
||||
static_cast<typename integral<F>::type>(flags);
|
||||
}
|
||||
|
||||
} // namespace bitfields
|
||||
} // namespace kutil
|
||||
|
||||
|
||||
Reference in New Issue
Block a user