51 template<
typename BITS_ENUM,
typename UNDERLYING =
unsigned long>
60 typedef Flags<BITS_ENUM, UNDERLYING>
type;
101 explicit constexpr operator bool ()
const
109 {
return type(lhs._v | rhs._v); }
113 {
return lhs |
type(rhs); }
117 {
return type(lhs._v & rhs._v); }
121 {
return lhs &
type(rhs); }
160 template<>
struct Int_for_size<sizeof(unsigned char), true>
161 {
typedef unsigned char type; };
164 (sizeof(unsigned short) > sizeof(unsigned char))>
165 {
typedef unsigned short type; };
167 template<>
struct Int_for_size<sizeof(unsigned),
168 (sizeof(unsigned) > sizeof(unsigned short))>
169 {
typedef unsigned type; };
171 template<>
struct Int_for_size<sizeof(unsigned long),
172 (sizeof(unsigned long) > sizeof(unsigned))>
173 {
typedef unsigned long type; };
175 template<>
struct Int_for_size<sizeof(unsigned long long),
176 (sizeof(unsigned long long) > sizeof(unsigned long))>
177 {
typedef unsigned long long type; };
199 template<
typename DT>
204 {
return DT(l.raw | r.raw); }
208 {
return DT(l.raw & r.raw); }
212 {
return DT(l.raw & ~r.raw); }
216 {
return l.raw == r.raw; }
220 {
return l.raw != r.raw; }
225 static_cast<DT *
>(
this)->raw |= r.raw;
226 return *
static_cast<DT *
>(
this);
232 static_cast<DT *
>(
this)->raw &= r.raw;
233 return *
static_cast<DT *
>(
this);
239 static_cast<DT *
>(
this)->raw &= ~r.raw;
240 return *
static_cast<DT *
>(
this);
244 explicit constexpr operator bool ()
const
245 {
return static_cast<DT
const *
>(
this)->raw != 0; }
249 {
return DT(~
static_cast<DT
const *
>(
this)->raw); }
260 template<
typename DT,
typename T>
277 template<
typename...>
using Void = void;
285 {
using type = T &&; };
289 {
using type =
typename __Add_rvalue_reference_helper<T>::type; };
293 =
typename Add_rvalue_reference<T>::type;
310 template<
bool V > struct
Bool
318 struct False : Bool<false> {};
322 struct True : Bool<true> {};
325 template<
typename T, T Value>
328 static T
const value = Value;
330 typedef T value_type;
359 template<typename T, bool = Is_enum<T>::value>
371 =
typename Underlying_type<T>::type;
382 template<
typename A,
typename B>
388 template<
bool,
typename =
void>
struct Enable_if {};
389 template<
typename T>
struct Enable_if<true, T> {
typedef T type; };
392 template<
bool Condition,
typename T =
void>
393 using Enable_if_t =
typename Enable_if<Condition, T>::type;
395 template<
typename T1,
typename T2,
typename T =
void>
396 struct Enable_if_same : Enable_if<Same<T1, T2>::value, T> {};
398 template<
typename T>
struct Remove_const {
typedef T type; };
399 template<
typename T>
struct Remove_const<T const> {
typedef T type; };
400 template<
typename T>
struct Remove_volatile {
typedef T type; };
401 template<
typename T>
struct Remove_volatile<T volatile> {
typedef T type; };
402 template<
typename T>
struct Remove_cv
403 {
typedef typename Remove_const<typename Remove_volatile<T>::type>::type type; };
405 template<
typename T>
struct Remove_pointer {
typedef T type; };
406 template<
typename T>
struct Remove_pointer<T*> {
typedef T type; };
407 template<
typename T>
struct Remove_reference {
typedef T type; };
408 template<
typename T>
struct Remove_reference<T&> {
typedef T type; };
409 template<
typename T>
struct Remove_pr {
typedef T type; };
410 template<
typename T>
struct Remove_pr<T&> {
typedef T type; };
411 template<
typename T>
struct Remove_pr<T*> {
typedef T type; };
464 typename = L4::Types::Enable_if_t<Enum_bitops::Enable<T>::value>>
470 typename = L4::Types::Enable_if_t<Enum_bitops::Enable<T>::value>>
476 typename = L4::Types::Enable_if_t<Enum_bitops::Enable<T>::value>>
485 typename = L4::Types::Enable_if_t<Enum_bitops::Enable<T>::value>>
491 typename = L4::Types::Enable_if_t<Enum_bitops::Enable<T>::value>>
500 typename = L4::Types::Enable_if_t<Enum_bitops::Enable<T>::value>>
506 typename = L4::Types::Enable_if_t<Enum_bitops::Enable<T>::value>>
constexpr Flags()
Make default Flags.
constexpr type operator~() const
Support ~ for Flags types.
constexpr Flags(None_type)
Make an empty bitmap.
friend constexpr type operator&(type lhs, type rhs)
Support & of two compatible Flags types.
UNDERLYING value_type
type of the underlying value
constexpr value_type as_value() const
Get the underlying value.
constexpr type & operator&=(type rhs)
Support &= of two compatible Flags types.
constexpr bool operator!() const
Support for if (!flags) syntax (test for empty flags).
friend constexpr type operator|(type lhs, type rhs)
Support | of two compatible Flags types.
constexpr type & clear(bits_enum_type flag)
Clear the given flag.
constexpr type & operator|=(type rhs)
Support |= of two compatible Flags types.
BITS_ENUM bits_enum_type
enum type defining a name for each bit
static constexpr type from_raw(value_type v)
Make flags from a raw value of value_type.
Flags< BITS_ENUM, UNDERLYING > type
the Flags<> type itself
constexpr Flags(BITS_ENUM e)
Make flags from bit name.
Bitwise operators on enumeration types.
constexpr T & operator|=(T &a, T const b) noexcept
Union and assign enum values.
constexpr T operator-(T l, T r) noexcept
Difference (intersect with negation, clear bits) enum values.
constexpr T operator~(T const a) noexcept
Negate enum value.
constexpr T operator|(T l, T r) noexcept
Union enum values.
constexpr L4::Types::Underlying_type_t< T > to_underlying(T const arg) noexcept
Convert enum value to its underlying type value.
constexpr T operator&(T l, T r) noexcept
Intersect enum values.
constexpr T & operator&=(T &a, T const b) noexcept
Intersect and assign enum values.
constexpr T & operator-=(T &a, T const b) noexcept
Difference (intersect with negation, clear bits) and assign enum values.
Mechanism to opt-in for enum bitwise operators.
L4 basic type helpers for C++.
typename Underlying_type< T >::type Underlying_type_t
Helper type for Underlying_type.
Add_rvalue_reference_t< T > declval() noexcept
Template for writing typed expressions in unevaluated contexts.
void Void
Map a sequence of any types to the void type.
typename Enable_if< Condition, T >::type Enable_if_t
Helper type for Enable_if.
typename Add_rvalue_reference< T >::type Add_rvalue_reference_t
Helper type for the Add_rvalue_reference.
L4 low-level kernel interface.
Check whether the given enum type opts in for the bitwise operators.
Marker for the opt-in ADL function.
Create an rvalue reference of the given type.
Bool< V > type
The meta type itself.
Mixin class to define a set of friend bitwise operators on DT.
constexpr DT & operator|=(DT const r)
bitwise or assignment for DT
friend constexpr DT operator-(DT l, DT r)
Bitwise difference (clear bits) for DT.
friend constexpr bool operator!=(DT l, DT r)
inequality for DT
constexpr DT operator~() const
bitwise negation for DT
constexpr DT & operator&=(DT const r)
bitwise and assignment for DT
friend constexpr DT operator&(DT l, DT r)
bitwise and for DT
constexpr DT & operator-=(DT const r)
Bitwise difference (clear bits) assignment for DT.
friend constexpr DT operator|(DT l, DT r)
bitwise or for DT
friend constexpr bool operator==(DT l, DT r)
equality for DT
constexpr Flags_t()=default
Default (uninitializing) constructor.
constexpr Flags_t(DT f)
Initialization from determinator type.
constexpr Flags_t(T f)
Explicit initialization from the underlying type.
static constexpr Flags_t None
Empty flags literal.
Metafunction to get an unsigned integral type for the given size.
Metafunction to get an integral type of the same size as T.
Int_for_size< sizeof(T)>::type type
The resulting unsigned integer type with the size like T.
Wrapper for a static constant of the given type.
Check whether the given type is an enumeration type.
Compare two data types for equality.
Get an underlying type of an enumeration type.
Helper template for Add_rvalue_reference.
Helper template for Underlying_type.