51 template<
typename BITS_ENUM,
typename UNDERLYING =
unsigned long>
101 explicit operator bool ()
const
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; };
195#define L4_TYPES_FLAGS_OPS_DEF(T) \
196 friend constexpr T operator ~ (T f) \
198 return T(~static_cast<typename L4::Types::Int_for_type<T>::type>(f)); \
201 friend constexpr T operator | (T l, T r) \
203 return T(static_cast<typename L4::Types::Int_for_type<T>::type>(l) \
204 | static_cast<typename L4::Types::Int_for_type<T>::type>(r)); \
207 friend constexpr T operator & (T l, T r) \
209 return T(static_cast<typename L4::Types::Int_for_type<T>::type>(l) \
210 & static_cast<typename L4::Types::Int_for_type<T>::type>(r)); \
195#define L4_TYPES_FLAGS_OPS_DEF(T) \ …
219 template<
typename DT>
224 {
return DT(l.raw | r.raw); }
228 {
return DT(l.raw & r.raw); }
232 {
return l.raw == r.raw; }
236 {
return l.raw != r.raw; }
241 static_cast<DT *
>(
this)->raw |= r.raw;
242 return *
static_cast<DT *
>(
this);
248 static_cast<DT *
>(
this)->raw &= r.raw;
249 return *
static_cast<DT *
>(
this);
253 explicit constexpr operator bool ()
const
255 return static_cast<DT
const *
>(
this)->raw != 0;
253 explicit constexpr operator bool ()
const {
…}
260 {
return DT(~
static_cast<DT
const *
>(
this)->raw); }
271 template<
typename DT,
typename T>
311 template<
typename A,
typename B>
317 template<
bool EXP,
typename T =
void>
struct Enable_if {};
318 template<
typename T>
struct Enable_if<true, T> {
typedef T type; };
320 template<
typename T1,
typename T2,
typename T =
void>
321 struct Enable_if_same : Enable_if<Same<T1, T2>::value, T> {};
323 template<
typename T>
struct Remove_const {
typedef T type; };
324 template<
typename T>
struct Remove_const<T const> {
typedef T type; };
325 template<
typename T>
struct Remove_volatile {
typedef T type; };
326 template<
typename T>
struct Remove_volatile<T volatile> {
typedef T type; };
327 template<
typename T>
struct Remove_cv
328 {
typedef typename Remove_const<typename Remove_volatile<T>::type>::type type; };
330 template<
typename T>
struct Remove_pointer {
typedef T type; };
331 template<
typename T>
struct Remove_pointer<T*> {
typedef T type; };
332 template<
typename T>
struct Remove_reference {
typedef T type; };
333 template<
typename T>
struct Remove_reference<T&> {
typedef T type; };
334 template<
typename T>
struct Remove_pr {
typedef T type; };
335 template<
typename T>
struct Remove_pr<T&> {
typedef T type; };
336 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.