51 template<
typename BITS_ENUM,
typename UNDERLYING =
unsigned long>
60 typedef Flags<BITS_ENUM, UNDERLYING>
type;
101 explicit 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); }
155 template<>
struct Int_for_size<sizeof(unsigned char), true>
156 {
typedef unsigned char type; };
159 (sizeof(unsigned short) > sizeof(unsigned char))>
160 {
typedef unsigned short type; };
162 template<>
struct Int_for_size<sizeof(unsigned),
163 (sizeof(unsigned) > sizeof(unsigned short))>
164 {
typedef unsigned type; };
166 template<>
struct Int_for_size<sizeof(unsigned long),
167 (sizeof(unsigned long) > sizeof(unsigned))>
168 {
typedef unsigned long type; };
170 template<>
struct Int_for_size<sizeof(unsigned long long),
171 (sizeof(unsigned long long) > sizeof(unsigned long))>
172 {
typedef unsigned long long type; };
194 template<
typename DT>
199 {
return DT(l.raw | r.raw); }
203 {
return DT(l.raw & r.raw); }
207 {
return DT(l.raw & ~r.raw); }
211 {
return l.raw == r.raw; }
215 {
return l.raw != r.raw; }
220 static_cast<DT *
>(
this)->raw |= r.raw;
221 return *
static_cast<DT *
>(
this);
227 static_cast<DT *
>(
this)->raw &= r.raw;
228 return *
static_cast<DT *
>(
this);
234 static_cast<DT *
>(
this)->raw &= ~r.raw;
235 return *
static_cast<DT *
>(
this);
239 explicit constexpr operator bool ()
const
240 {
return static_cast<DT
const *
>(
this)->raw != 0; }
244 {
return DT(~
static_cast<DT
const *
>(
this)->raw); }
255 template<
typename DT,
typename T>
267 template<
typename...>
using Void = void;
275 {
using type = T &&; };
279 {
using type =
typename __Add_rvalue_reference_helper<T>::type; };
283 =
typename Add_rvalue_reference<T>::type;
300 template<
bool V > struct
Bool
308 struct False : Bool<false> {};
312 struct True : Bool<true> {};
315 template<
typename T, T Value>
318 static T
const value = Value;
320 typedef T value_type;
349 template<typename T, bool = Is_enum<T>::value>
361 =
typename Underlying_type<T>::type;
372 template<
typename A,
typename B>
378 template<
bool,
typename =
void>
struct Enable_if {};
379 template<
typename T>
struct Enable_if<true, T> {
typedef T type; };
382 template<
bool Condition,
typename T =
void>
383 using Enable_if_t =
typename Enable_if<Condition, T>::type;
385 template<
typename T1,
typename T2,
typename T =
void>
386 struct Enable_if_same : Enable_if<Same<T1, T2>::value, T> {};
388 template<
typename T>
struct Remove_const {
typedef T type; };
389 template<
typename T>
struct Remove_const<T const> {
typedef T type; };
390 template<
typename T>
struct Remove_volatile {
typedef T type; };
391 template<
typename T>
struct Remove_volatile<T volatile> {
typedef T type; };
392 template<
typename T>
struct Remove_cv
393 {
typedef typename Remove_const<typename Remove_volatile<T>::type>::type type; };
395 template<
typename T>
struct Remove_pointer {
typedef T type; };
396 template<
typename T>
struct Remove_pointer<T*> {
typedef T type; };
397 template<
typename T>
struct Remove_reference {
typedef T type; };
398 template<
typename T>
struct Remove_reference<T&> {
typedef T type; };
399 template<
typename T>
struct Remove_pr {
typedef T type; };
400 template<
typename T>
struct Remove_pr<T&> {
typedef T type; };
401 template<
typename T>
struct Remove_pr<T*> {
typedef T type; };
454 typename = L4::Types::Enable_if_t<Enum_bitops::Enable<T>::value>>
460 typename = L4::Types::Enable_if_t<Enum_bitops::Enable<T>::value>>
466 typename = L4::Types::Enable_if_t<Enum_bitops::Enable<T>::value>>
475 typename = L4::Types::Enable_if_t<Enum_bitops::Enable<T>::value>>
481 typename = L4::Types::Enable_if_t<Enum_bitops::Enable<T>::value>>
490 typename = L4::Types::Enable_if_t<Enum_bitops::Enable<T>::value>>
496 typename = L4::Types::Enable_if_t<Enum_bitops::Enable<T>::value>>
value_type as_value() const
Get the underlying value.
static type from_raw(value_type v)
Make flags from a raw value of value_type.
type & clear(bits_enum_type flag)
Clear the given flag.
type operator~() const
Support ~ for Flags types.
UNDERLYING value_type
type of the underlying value
type & operator|=(type rhs)
Support |= of two compatible Flags types.
Flags()
Make default Flags.
friend type operator|(type lhs, type rhs)
Support | of two compatible Flags types.
friend type operator&(type lhs, type rhs)
Support & of two compatible Flags types.
BITS_ENUM bits_enum_type
enum type defining a name for each bit
bool operator!() const
Support for if (!flags) syntax (test for empty flags).
Flags(None_type)
Make an empty bitmap.
Flags< BITS_ENUM, UNDERLYING > type
the Flags<> type itself
Flags(BITS_ENUM e)
Make flags from bit name.
type & operator&=(type rhs)
Support &= of two compatible Flags types.
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
Flags_t()=default
Default (uninitializing) constructor.
constexpr Flags_t(T f)
Explicit initialization from the underlying type.
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.