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>
280 template<
typename...>
using Void = void;
288 {
using type = T &&; };
292 {
using type =
typename __Add_rvalue_reference_helper<T>::type; };
296 =
typename Add_rvalue_reference<T>::type;
313 template<
bool V > struct
Bool
321 struct False : Bool<false> {};
325 struct True : Bool<true> {};
328 template<
typename T, T Value>
331 static T
const value = Value;
333 typedef T value_type;
362 template<typename T, bool = Is_enum<T>::value>
374 =
typename Underlying_type<T>::type;
385 template<
typename A,
typename B>
391 template<
typename T1,
typename T2 >
392 inline constexpr bool Same_v = Same<T1, T2>::value;
395 template <
typename T,
template <
typename...>
typename Template>
398 template <
template <
typename...>
typename Template,
typename... Args>
401 template <
typename T,
template <
typename...>
typename Template>
402 inline constexpr bool Same_template_v = Same_template<T, Template>::value;
404 template<
bool,
typename =
void>
struct Enable_if {};
405 template<
typename T>
struct Enable_if<true, T> {
using type = T; };
408 template<
bool Condition,
typename T =
void>
409 using Enable_if_t =
typename Enable_if<Condition, T>::type;
411 template<
typename T1,
typename T2,
typename T =
void>
412 struct Enable_if_same : Enable_if<Same_v<T1, T2>, T> {};
414 template<
typename T>
struct Remove_const {
using type = T; };
415 template<
typename T>
struct Remove_const<T const> {
using type = T; };
416 template<
typename T>
using Remove_const_t =
typename Remove_const<T>::type;
418 template<
typename T>
struct Remove_volatile {
using type = T; };
419 template<
typename T>
struct Remove_volatile<T volatile> {
using type = T; };
420 template<
typename T>
using Remove_volatile_t =
typename Remove_volatile<T>::type;
422 template<
typename T>
struct Remove_cv
423 {
using type = Remove_const_t<Remove_volatile_t<T>>; };
424 template<
typename T>
using Remove_cv_t =
typename Remove_cv<T>::type;
426 template<
typename T>
struct Remove_pointer {
using type = T; };
427 template<
typename T>
struct Remove_pointer<T*> {
using type = T; };
428 template<
typename T>
using Remove_pointer_t =
typename Remove_pointer<T>::type;
430 template<
typename T>
struct Remove_reference {
using type = T; };
431 template<
typename T>
struct Remove_reference<T&> {
using type = T; };
432 template<
typename T>
using Remove_reference_t =
typename Remove_reference<T>::type;
434 template<
typename T>
struct Remove_pr {
using type = T; };
435 template<
typename T>
struct Remove_pr<T&> {
using type = T; };
436 template<
typename T>
struct Remove_pr<T*> {
using type = T; };
437 template<
typename T>
using Remove_pr_t =
typename Remove_pr<T>::type;
441 forward(Remove_reference_t<T> &t)
442 {
return static_cast<T &&
>(t); }
446 forward(Remove_reference_t<T> &&t)
447 {
return static_cast<T &&
>(t); }
450 constexpr Remove_reference_t<T> &&
451 move(T &&t) {
return static_cast<Remove_reference_t<T> &&
>(t); }
453 template<
typename... >
using Void_t = void;
506 typename = L4::Types::Enable_if_t<Enum_bitops::Enable<T>::value>>
512 typename = L4::Types::Enable_if_t<Enum_bitops::Enable<T>::value>>
518 typename = L4::Types::Enable_if_t<Enum_bitops::Enable<T>::value>>
527 typename = L4::Types::Enable_if_t<Enum_bitops::Enable<T>::value>>
533 typename = L4::Types::Enable_if_t<Enum_bitops::Enable<T>::value>>
542 typename = L4::Types::Enable_if_t<Enum_bitops::Enable<T>::value>>
548 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()=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.
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 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.