LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
util::flags::Bits_t< Storage > Struct Template Reference

Type identifying a set of bits. More...

#include "BitMask.h"

Public Types

using Storage_t = Storage
 
using This_t = Bits_t< Storage >
 This type. More...
 
using Flag_t = util::flags::Flag_t< Storage_t >
 Type of flag matching our storage. More...
 

Public Member Functions

constexpr Bits_t ()=default
 Default constructor: no bit set. More...
 
constexpr Bits_t (Flag_t flag)
 Constructs from a single flag. More...
 
constexpr Bits_t (Storage_t bits)
 Constructs from a set of bits. More...
 
constexpr operator bool () const
 Returns true if there is at least one bit set. More...
 
constexpr bool operator! () const
 Returns true if there is no bit set. More...
 
Bit query operations
constexpr bool empty () const
 Returns whether there is no bit set at all. More...
 
constexpr bool all (This_t bits) const
 Returns wether all bits are set. More...
 
constexpr bool any (This_t bits) const
 Returns wether at least one of the bits is set. More...
 
constexpr bool none (This_t bits) const
 Returns wether all bits are unset. More...
 
constexpr bool only (This_t bits) const
 Returns wether no bits are set except (at most) the specified ones. More...
 
Bit change operations
void set (This_t bits)
 Sets the specified bits. More...
 
void unset (This_t bits)
 Unsets the specified bits. More...
 
void keepOnly (This_t bits)
 Unsets the bits which are not in bits argument. More...
 
void clear ()
 Unsets all bits. More...
 
Bit manipulation operations returning a new object
constexpr This_t select (This_t bits) const
 Returns only the bits that are also present in the argument. More...
 
constexpr This_t exclude (This_t bits) const
 Returns only the bits that are not present in the argument. More...
 
constexpr This_t combine (This_t bits) const
 Returns our bits, plus the ones present in the argument. More...
 
constexpr This_t invert () const
 Returns all and only the bits that are not set. More...
 
Comparison operators for bits
constexpr bool operator== (This_t other) const
 
constexpr bool operator!= (This_t other) const
 
constexpr bool operator< (This_t other) const
 
constexpr bool operator> (This_t other) const
 
constexpr bool operator<= (This_t other) const
 
constexpr bool operator>= (This_t other) const
 

Static Public Member Functions

static void setBits (Storage_t &base, Storage_t bits)
 Returns data with all bits from base and from bits set. More...
 
static void onlyBits (Storage_t &base, Storage_t bits)
 
static void unsetBits (Storage_t &base, Storage_t bits)
 Returns data with all bits from base, but the ones from bits unset. More...
 

Public Attributes

Storage_t data = {0}
 The bits representing all set bits. More...
 

Detailed Description

template<typename Storage>
struct util::flags::Bits_t< Storage >

Type identifying a set of bits.

Definition at line 212 of file BitMask.h.

Member Typedef Documentation

template<typename Storage>
using util::flags::Bits_t< Storage >::Flag_t = util::flags::Flag_t<Storage_t>

Type of flag matching our storage.

Definition at line 217 of file BitMask.h.

template<typename Storage>
using util::flags::Bits_t< Storage >::Storage_t = Storage

Definition at line 213 of file BitMask.h.

template<typename Storage>
using util::flags::Bits_t< Storage >::This_t = Bits_t<Storage>

This type.

Definition at line 214 of file BitMask.h.

Constructor & Destructor Documentation

template<typename Storage>
constexpr util::flags::Bits_t< Storage >::Bits_t ( )
default

Default constructor: no bit set.

template<typename Storage>
constexpr util::flags::Bits_t< Storage >::Bits_t ( Flag_t  flag)
inline

Constructs from a single flag.

Definition at line 225 of file BitMask.h.

225 : data(flag.bits) {}
Storage_t data
The bits representing all set bits.
Definition: BitMask.h:219
template<typename Storage>
constexpr util::flags::Bits_t< Storage >::Bits_t ( Storage_t  bits)
inlineexplicit

Constructs from a set of bits.

Definition at line 228 of file BitMask.h.

228 : data(bits) {}
Storage_t data
The bits representing all set bits.
Definition: BitMask.h:219

Member Function Documentation

template<typename Storage>
constexpr bool util::flags::Bits_t< Storage >::all ( This_t  bits) const

Returns wether all bits are set.

template<typename Storage>
constexpr bool util::flags::Bits_t< Storage >::any ( This_t  bits) const

Returns wether at least one of the bits is set.

template<typename Storage>
void util::flags::Bits_t< Storage >::clear ( )
inline

Unsets all bits.

Definition at line 263 of file BitMask.h.

263 { data = 0; }
Storage_t data
The bits representing all set bits.
Definition: BitMask.h:219
template<typename Storage>
constexpr This_t util::flags::Bits_t< Storage >::combine ( This_t  bits) const

Returns our bits, plus the ones present in the argument.

template<typename Storage>
constexpr bool util::flags::Bits_t< Storage >::empty ( ) const
inline

Returns whether there is no bit set at all.

Definition at line 234 of file BitMask.h.

234 { return data == Storage_t(0); }
Storage Storage_t
Definition: BitMask.h:213
Storage_t data
The bits representing all set bits.
Definition: BitMask.h:219
template<typename Storage>
constexpr This_t util::flags::Bits_t< Storage >::exclude ( This_t  bits) const

Returns only the bits that are not present in the argument.

template<typename Storage>
constexpr This_t util::flags::Bits_t< Storage >::invert ( ) const

Returns all and only the bits that are not set.

template<typename Storage>
void util::flags::Bits_t< Storage >::keepOnly ( This_t  bits)

Unsets the bits which are not in bits argument.

template<typename Storage>
constexpr bool util::flags::Bits_t< Storage >::none ( This_t  bits) const

Returns wether all bits are unset.

template<typename Storage>
constexpr bool util::flags::Bits_t< Storage >::only ( This_t  bits) const

Returns wether no bits are set except (at most) the specified ones.

template<typename Storage>
static void util::flags::Bits_t< Storage >::onlyBits ( Storage_t base,
Storage_t  bits 
)
inlinestatic

Returns data with all bits from base which are also in bits argument.

Definition at line 307 of file BitMask.h.

307 { base &= bits; }
template<typename Storage>
constexpr util::flags::Bits_t< Storage >::operator bool ( ) const
inlineexplicit

Returns true if there is at least one bit set.

Definition at line 297 of file BitMask.h.

297 { return bool(data); }
Storage_t data
The bits representing all set bits.
Definition: BitMask.h:219
template<typename Storage>
constexpr bool util::flags::Bits_t< Storage >::operator! ( ) const
inline

Returns true if there is no bit set.

Definition at line 300 of file BitMask.h.

300 { return !data; }
Storage_t data
The bits representing all set bits.
Definition: BitMask.h:219
template<typename Storage>
constexpr bool util::flags::Bits_t< Storage >::operator!= ( This_t  other) const
inline

Definition at line 288 of file BitMask.h.

288 { return data != other.data; }
Storage_t data
The bits representing all set bits.
Definition: BitMask.h:219
template<typename Storage>
constexpr bool util::flags::Bits_t< Storage >::operator< ( This_t  other) const
inline

Definition at line 289 of file BitMask.h.

289 { return data < other.data; }
Storage_t data
The bits representing all set bits.
Definition: BitMask.h:219
template<typename Storage>
constexpr bool util::flags::Bits_t< Storage >::operator<= ( This_t  other) const
inline

Definition at line 291 of file BitMask.h.

291 { return data <= other.data; }
Storage_t data
The bits representing all set bits.
Definition: BitMask.h:219
template<typename Storage>
constexpr bool util::flags::Bits_t< Storage >::operator== ( This_t  other) const
inline

Definition at line 287 of file BitMask.h.

287 { return data == other.data; }
Storage_t data
The bits representing all set bits.
Definition: BitMask.h:219
template<typename Storage>
constexpr bool util::flags::Bits_t< Storage >::operator> ( This_t  other) const
inline

Definition at line 290 of file BitMask.h.

290 { return data > other.data; }
Storage_t data
The bits representing all set bits.
Definition: BitMask.h:219
template<typename Storage>
constexpr bool util::flags::Bits_t< Storage >::operator>= ( This_t  other) const
inline

Definition at line 292 of file BitMask.h.

292 { return data >= other.data; }
Storage_t data
The bits representing all set bits.
Definition: BitMask.h:219
template<typename Storage>
constexpr This_t util::flags::Bits_t< Storage >::select ( This_t  bits) const

Returns only the bits that are also present in the argument.

template<typename Storage>
void util::flags::Bits_t< Storage >::set ( This_t  bits)

Sets the specified bits.

template<typename Storage>
static void util::flags::Bits_t< Storage >::setBits ( Storage_t base,
Storage_t  bits 
)
inlinestatic

Returns data with all bits from base and from bits set.

Definition at line 303 of file BitMask.h.

303 { base |= bits; }
template<typename Storage>
void util::flags::Bits_t< Storage >::unset ( This_t  bits)

Unsets the specified bits.

template<typename Storage>
static void util::flags::Bits_t< Storage >::unsetBits ( Storage_t base,
Storage_t  bits 
)
inlinestatic

Returns data with all bits from base, but the ones from bits unset.

Definition at line 310 of file BitMask.h.

310 { onlyBits(base, ~bits); }
static void onlyBits(Storage_t &base, Storage_t bits)
Definition: BitMask.h:307

Member Data Documentation


The documentation for this struct was generated from the following file: