20#ifndef INCLUDED_O3TL_TYPED_FLAGS_SET_HXX
21#define INCLUDED_O3TL_TYPED_FLAGS_SET_HXX
34template<
typename T>
constexpr
35typename std::enable_if<std::is_signed<T>::value,
bool>::type
isNonNegative(
41template<
typename T>
constexpr
42typename std::enable_if<std::is_unsigned<T>::value,
bool>::type
isNonNegative(T)
64template<typename E, typename std::underlying_type<E>::type
M>
67 M >= 0,
"is_typed_flags expects only non-negative bit values");
75 explicit constexpr Wrap(
typename std::underlying_type<E>::type value):
80 static_cast<typename std::underlying_type<E>::type
>(~0) ==
M
86 constexpr operator E()
const {
return static_cast<E>(
value_); }
88 explicit constexpr operator typename std::underlying_type<E>::type()
92 explicit constexpr operator bool()
const {
return value_ != 0; }
95 typename std::underlying_type<E>::type
value_;
98 static typename std::underlying_type<E>::type
const mask =
M;
118 &
~o3tl::to_underlying<E>(rhs));
143 ^ o3tl::to_underlying<E>(rhs));
153 o3tl::to_underlying<E>(lhs)
157template<
typename W>
constexpr
161 return static_cast<W
>(
162 o3tl::to_underlying<typename W::Unwrapped::Self>(lhs)
163 ^ o3tl::to_underlying<typename W::Unwrapped::Self>(rhs));
187 & o3tl::to_underlying<E>(rhs));
197 o3tl::to_underlying<E>(lhs)
201template<
typename W>
constexpr
205 return static_cast<W
>(
206 o3tl::to_underlying<typename W::Unwrapped::Self>(lhs)
207 & o3tl::to_underlying<typename W::Unwrapped::Self>(rhs));
231 | o3tl::to_underlying<E>(rhs));
241 o3tl::to_underlying<E>(lhs)
245template<
typename W>
constexpr
249 return static_cast<W
>(
250 o3tl::to_underlying<typename W::Unwrapped::Self>(lhs)
251 | o3tl::to_underlying<typename W::Unwrapped::Self>(rhs));
std::underlying_type< E >::type value_
constexpr Wrap(typename std::underlying_type< E >::type value)
constexpr std::enable_if< std::is_signed< T >::value, bool >::type isNonNegative(T value)
constexpr std::underlying_type_t< T > to_underlying(T e)
Mark a (scoped) enumeration as a set of bit flags, with accompanying operations.
static std::underlying_type< E >::type const mask
constexpr o3tl::typed_flags< E >::Wrap operator^(E lhs, E rhs)
constexpr o3tl::typed_flags< E >::Wrap operator&(E lhs, E rhs)
constexpr o3tl::typed_flags< E >::Wrap operator|(E lhs, E rhs)
o3tl::typed_flags< E >::Self operator^=(E &lhs, E rhs)
o3tl::typed_flags< E >::Self operator|=(E &lhs, E rhs)
o3tl::typed_flags< E >::Self operator&=(E &lhs, E rhs)
constexpr o3tl::typed_flags< E >::Wrap operator~(E rhs)