51 template<
typename BITS_ENUM,
typename UNDERLYING =
unsigned long>
60 using type = Flags<BITS_ENUM, UNDERLYING>;
81 constexpr Flags() noexcept : _v(0) {}
91 constexpr Flags(BITS_ENUM e) noexcept
103 explicit constexpr operator bool () const noexcept
107 constexpr bool operator ! () const noexcept {
return _v == 0; }
111 {
return type(lhs._v | rhs._v); }
115 {
return lhs |
type(rhs); }
119 {
return type(lhs._v & rhs._v); }
123 {
return lhs &
type(rhs); }
127 { _v |= rhs._v;
return *
this; }
163 template<>
struct Int_for_size<sizeof(unsigned char), true>
164 {
using type =
unsigned char; };
167 (sizeof(unsigned short) > sizeof(unsigned char))>
168 {
using type =
unsigned short; };
170 template<>
struct Int_for_size<sizeof(unsigned),
171 (sizeof(unsigned) > sizeof(unsigned short))>
172 {
using type = unsigned; };
174 template<>
struct Int_for_size<sizeof(unsigned long),
175 (sizeof(unsigned long) > sizeof(unsigned))>
176 {
using type =
unsigned long; };
178 template<>
struct Int_for_size<sizeof(unsigned long long),
179 (sizeof(unsigned long long) > sizeof(unsigned long))>
180 {
using type =
unsigned long long; };
202 template<
typename DT>
207 {
return DT(l.raw | r.raw); }
211 {
return DT(l.raw & r.raw); }
215 {
return DT(l.raw & ~r.raw); }
219 {
return l.raw == r.raw; }
223 {
return l.raw != r.raw; }
228 static_cast<DT *
>(
this)->raw |= r.raw;
229 return *
static_cast<DT *
>(
this);
235 static_cast<DT *
>(
this)->raw &= r.raw;
236 return *
static_cast<DT *
>(
this);
242 static_cast<DT *
>(
this)->raw &= ~r.raw;
243 return *
static_cast<DT *
>(
this);
247 explicit constexpr operator bool ()
const
248 {
return static_cast<DT
const *
>(
this)->raw != 0; }
252 {
return DT(~
static_cast<DT
const *
>(
this)->raw); }
263 template<
typename DT,
typename T>
282 template<
typename...>
using Void = void;
290 {
using type = T &&; };
294 {
using type =
typename __Add_rvalue_reference_helper<T>::type; };
298 =
typename Add_rvalue_reference<T>::type;
315 template<
bool V > struct
Bool
330 template<
typename T, T Value>
333 static T
const value = Value;
335 typedef T value_type;
367 inline constexpr bool Is_trivially_copyable_v = __is_trivially_copyable(T);
380 template<typename T, bool = Is_enum<T>::value>
392 =
typename Underlying_type<T>::type;
403 template<
typename A,
typename B>
409 template<
typename T1,
typename T2 >
410 inline constexpr bool Same_v = Same<T1, T2>::value;
413 template <
typename T,
template <
typename...>
typename Template>
416 template <
template <
typename...>
typename Template,
typename... Args>
419 template <
typename T,
template <
typename...>
typename Template>
420 inline constexpr bool Same_template_v = Same_template<T, Template>::value;
422 template<
bool,
typename =
void>
struct Enable_if {};
423 template<
typename T>
struct Enable_if<true, T> {
using type = T; };
426 template<
bool Condition,
typename T =
void>
427 using Enable_if_t =
typename Enable_if<Condition, T>::type;
429 template<
typename T1,
typename T2,
typename T =
void>
430 struct Enable_if_same : Enable_if<Same_v<T1, T2>, T> {};
432 template<
typename T>
struct Remove_const {
using type = T; };
433 template<
typename T>
struct Remove_const<T const> {
using type = T; };
434 template<
typename T>
using Remove_const_t =
typename Remove_const<T>::type;
436 template<
typename T>
struct Remove_volatile {
using type = T; };
437 template<
typename T>
struct Remove_volatile<T volatile> {
using type = T; };
438 template<
typename T>
using Remove_volatile_t =
typename Remove_volatile<T>::type;
440 template<
typename T>
struct Remove_cv
441 {
using type = Remove_const_t<Remove_volatile_t<T>>; };
442 template<
typename T>
using Remove_cv_t =
typename Remove_cv<T>::type;
444 template<
typename T>
struct Remove_pointer {
using type = T; };
445 template<
typename T>
struct Remove_pointer<T*> {
using type = T; };
446 template<
typename T>
using Remove_pointer_t =
typename Remove_pointer<T>::type;
448 template<
typename T>
struct Remove_reference {
using type = T; };
449 template<
typename T>
struct Remove_reference<T&> {
using type = T; };
450 template<
typename T>
using Remove_reference_t =
typename Remove_reference<T>::type;
452 template<
typename T>
struct Remove_pr {
using type = T; };
453 template<
typename T>
struct Remove_pr<T&> {
using type = T; };
454 template<
typename T>
struct Remove_pr<T*> {
using type = T; };
455 template<
typename T>
using Remove_pr_t =
typename Remove_pr<T>::type;
459 forward(Remove_reference_t<T> &t)
460 {
return static_cast<T &&
>(t); }
464 forward(Remove_reference_t<T> &&t)
465 {
return static_cast<T &&
>(t); }
468 constexpr Remove_reference_t<T> &&
469 move(T &&t) {
return static_cast<Remove_reference_t<T> &&
>(t); }
471 template<
typename... >
using Void_t = void;
524 typename = L4::Types::Enable_if_t<Enum_bitops::Enable<T>::value>>
530 typename = L4::Types::Enable_if_t<Enum_bitops::Enable<T>::value>>
536 typename = L4::Types::Enable_if_t<Enum_bitops::Enable<T>::value>>
545 typename = L4::Types::Enable_if_t<Enum_bitops::Enable<T>::value>>
551 typename = L4::Types::Enable_if_t<Enum_bitops::Enable<T>::value>>
560 typename = L4::Types::Enable_if_t<Enum_bitops::Enable<T>::value>>
566 typename = L4::Types::Enable_if_t<Enum_bitops::Enable<T>::value>>
constexpr Flags(None_type) noexcept
Make an empty bitmap.
constexpr type & clear(bits_enum_type flag) noexcept
Clear the given flag.
UNDERLYING value_type
type of the underlying value
constexpr Flags() noexcept
Make default Flags.
friend constexpr type operator&(type lhs, type rhs) noexcept
Support & of two compatible Flags types.
Flags< BITS_ENUM, UNDERLYING > type
the Flags<> type itself
BITS_ENUM bits_enum_type
enum type defining a name for each bit
friend constexpr type operator|(type lhs, type rhs) noexcept
Support | of two compatible Flags types.
constexpr type & operator&=(type rhs)
Support &= of two compatible Flags types.
constexpr type & operator|=(type rhs) noexcept
Support |= of two compatible Flags types.
constexpr Flags(BITS_ENUM e) noexcept
Make flags from bit name.
constexpr bool operator!() const noexcept
Support for if (!flags) syntax (test for empty flags).
constexpr type operator~() const noexcept
Support ~ for Flags types.
static constexpr type from_raw(value_type v) noexcept
Make flags from a raw value of value_type.
constexpr value_type as_value() const noexcept
Get the underlying value.
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(None_type)
Constructor to create an empty value.
constexpr Flags_t()=default
Default constructor with no flag set.
constexpr Flags_t(DT f)
Initialization from determinator type.
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.
typename 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.
Check whether the given type is trivially copyable.
Check if a type T is an instantiation of a given template.
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.