Kouta
A small application framework based on Boost
kouta::utils::EnumSet< TEnum > Class Template Reference

#include <enum-set.hpp>

Inheritance diagram for kouta::utils::EnumSet< TEnum >:
Collaboration diagram for kouta::utils::EnumSet< TEnum >:

Public Types

using EnumType = TEnum
 Enumeration type used. More...
 
using BaseType = std::bitset< static_cast< std::size_t >(TEnum::_Total)>
 Base biset type. More...
 
using reference = BaseType::reference
 

Public Member Functions

 EnumSet (std::initializer_list< TEnum > values)
 Constructor from a set of values. More...
 
bool operator[] (EnumType pos) const
 Access a specific bit. More...
 
reference operator[] (EnumType pos)
 Access a specific bit. More...
 
bool test (EnumType pos) const
 Access a specific bit. More...
 
EnumSetset (EnumType pos, bool value=true)
 Set the value of a specific bit. More...
 

Member Typedef Documentation

◆ BaseType

template<class TEnum >
using kouta::utils::EnumSet< TEnum >::BaseType = std::bitset<static_cast<std::size_t>(TEnum::_Total)>

◆ EnumType

template<class TEnum >
using kouta::utils::EnumSet< TEnum >::EnumType = TEnum

◆ reference

template<class TEnum >
using kouta::utils::EnumSet< TEnum >::reference = BaseType::reference

Constructor & Destructor Documentation

◆ EnumSet()

template<class TEnum >
kouta::utils::EnumSet< TEnum >::EnumSet ( std::initializer_list< TEnum >  values)
inline

Constructor from a set of values.

Parameters
[in]valuesValues to set.
Examples
/home/runner/work/kouta/kouta/include/kouta/utils/enum-set.hpp.

Member Function Documentation

◆ operator[]() [1/2]

template<class TEnum >
reference kouta::utils::EnumSet< TEnum >::operator[] ( EnumType  pos)
inline

Access a specific bit.

Note
Does not perform any bound checking.
Parameters
[in]posPosition to check.
Returns
Reference to the bit.

◆ operator[]() [2/2]

template<class TEnum >
bool kouta::utils::EnumSet< TEnum >::operator[] ( EnumType  pos) const
inline

Access a specific bit.

Note
Does not perform any bound checking.
Parameters
[in]posPosition to check.
Returns
Value of the bit.
Examples
/home/runner/work/kouta/kouta/include/kouta/utils/enum-set.hpp.

◆ set()

template<class TEnum >
EnumSet& kouta::utils::EnumSet< TEnum >::set ( EnumType  pos,
bool  value = true 
)
inline

Set the value of a specific bit.

Parameters
[in]posPosition to set.
[in]valueValue to set.
Returns
Reference to this object for chaining
Exceptions
std::out_of_rangeif pos does not correspond to a valid position within the bitset.
Examples
/home/runner/work/kouta/kouta/include/kouta/utils/enum-set.hpp.

◆ test()

template<class TEnum >
bool kouta::utils::EnumSet< TEnum >::test ( EnumType  pos) const
inline

Access a specific bit.

Parameters
[in]posPosition to check.
Returns
Value of the bit.
Exceptions
std::out_of_rangeif pos does not correspond to a valid position within the bitset.
Examples
/home/runner/work/kouta/kouta/include/kouta/utils/enum-set.hpp.

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