62 template<
typename BITS_ENUM,
typename UNDERLYING =
unsigned long>
112 explicit operator bool ()
const
120 {
return type(lhs._v | rhs._v); }
124 {
return lhs |
type(rhs); }
128 {
return type(lhs._v & rhs._v); }
132 {
return lhs &
type(rhs); }
166 template<>
struct Int_for_size<sizeof(unsigned char), true>
167 {
typedef unsigned char type; };
170 (sizeof(unsigned short) > sizeof(unsigned char))>
171 {
typedef unsigned short type; };
173 template<>
struct Int_for_size<sizeof(unsigned),
174 (sizeof(unsigned) > sizeof(unsigned short))>
175 {
typedef unsigned type; };
177 template<>
struct Int_for_size<sizeof(unsigned long),
178 (sizeof(unsigned long) > sizeof(unsigned))>
179 {
typedef unsigned long type; };
181 template<>
struct Int_for_size<sizeof(unsigned long long),
182 (sizeof(unsigned long long) > sizeof(unsigned long))>
183 {
typedef unsigned long long type; };
206#define L4_TYPES_FLAGS_OPS_DEF(T) \
207 friend constexpr T operator ~ (T f) \
209 return T(~static_cast<typename L4::Types::Int_for_type<T>::type>(f)); \
212 friend constexpr T operator | (T l, T r) \
214 return T(static_cast<typename L4::Types::Int_for_type<T>::type>(l) \
215 | static_cast<typename L4::Types::Int_for_type<T>::type>(r)); \
218 friend constexpr T operator & (T l, T r) \
220 return T(static_cast<typename L4::Types::Int_for_type<T>::type>(l) \
221 & static_cast<typename L4::Types::Int_for_type<T>::type>(r)); \
230 template<
typename DT>
235 {
return DT(l.raw | r.raw); }
239 {
return DT(l.raw & r.raw); }
243 {
return l.raw == r.raw; }
247 {
return l.raw != r.raw; }
252 static_cast<DT *
>(
this)->raw |= r.raw;
253 return *
static_cast<DT *
>(
this);
259 static_cast<DT *
>(
this)->raw &= r.raw;
260 return *
static_cast<DT *
>(
this);
264 explicit constexpr operator bool ()
const
266 return static_cast<DT
const *
>(
this)->raw != 0;
271 {
return DT(~
static_cast<DT
const *
>(
this)->raw); }
282 template<
typename DT,
typename T>
322 template<
typename A,
typename B>
328 template<
bool EXP,
typename T =
void>
struct Enable_if {};
329 template<
typename T>
struct Enable_if<true, T> {
typedef T type; };
331 template<
typename T1,
typename T2,
typename T =
void>
332 struct Enable_if_same : Enable_if<Same<T1, T2>::value, T> {};
334 template<
typename T>
struct Remove_const {
typedef T type; };
335 template<
typename T>
struct Remove_const<T const> {
typedef T type; };
336 template<
typename T>
struct Remove_volatile {
typedef T type; };
337 template<
typename T>
struct Remove_volatile<T volatile> {
typedef T type; };
338 template<
typename T>
struct Remove_cv
339 {
typedef typename Remove_const<typename Remove_volatile<T>::type>::type type; };
341 template<
typename T>
struct Remove_pointer {
typedef T type; };
342 template<
typename T>
struct Remove_pointer<T*> {
typedef T type; };
343 template<
typename T>
struct Remove_reference {
typedef T type; };
344 template<
typename T>
struct Remove_reference<T&> {
typedef T type; };
345 template<
typename T>
struct Remove_pr {
typedef T type; };
346 template<
typename T>
struct Remove_pr<T&> {
typedef T type; };
347 template<
typename T>
struct Remove_pr<T*> {
typedef T type; };
Template for defining typical Flags bitmaps.
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.
None_type
The none type to get an empty bitmap.
@ None
Use this to get an empty bitmap.
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.
L4 low-level kernel interface.
Bool< V > type
The meta type itself.
Mixin class to define a set of friend bitwise operators on DT.
DT operator|=(DT r)
bitwise or assignment for DT
friend constexpr bool operator!=(DT l, DT r)
inequality for DT
constexpr DT operator~() const
bitwise negation for DT
friend constexpr DT operator&(DT l, DT r)
bitwise and for DT
DT operator&=(DT r)
bitwise and 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
Template type to define a flags type with bitwise operations.
Flags_t()=default
Default (uninitializing) costructor.
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.
Compare two data types for equality.