OpenTTD Source: EnumBitSet< Tenum, Tstorage, Tend_value > Class Template Reference

OpenTTD Source 15.3

Public Types | Public Member Functions | Static Public Member Functions | Private Types
EnumBitSet< Tenum, Tstorage, Tend_value > Class Template Reference

Enum-as-bit-set wrapper. More...

`#include <enum_type.hpp>`

Inheritance diagram for EnumBitSet< Tenum, Tstorage, Tend_value >:

## Public Types
using | EnumType = BaseClass::ValueType
Public Types inherited from BaseBitSet< Timpl, Tvalue_type, Tstorage, Tmask >
using | ValueType = Tvalue_type
| Value type of this BaseBitSet.
using | BaseType = Tstorage
| Storage type of this BaseBitSet, be ConvertibleThroughBase.

## Public Member Functions
constexpr | EnumBitSet (Tenum value)
constexpr | EnumBitSet (Tstorage data)
constexpr | EnumBitSet (std::initializer_list< const Tenum > values)
| Construct an EnumBitSet from a list of enum values.
constexpr auto | operator<=> (const EnumBitSet &) const noexcept=default
Public Member Functions inherited from BaseBitSet< Timpl, Tvalue_type, Tstorage, Tmask >
constexpr | BaseBitSet (Tstorage data)
constexpr auto | operator<=> (const BaseBitSet &) const noexcept=default
constexpr Timpl & | Set ()
| Set all bits.
constexpr Timpl & | Set (Tvalue_type value)
| Set the value-th bit.
constexpr Timpl & | Set (const Timpl &other)
| Set values from another bitset.
constexpr Timpl & | Set (Tvalue_type value, bool set)
| Assign the value-th bit.
constexpr Timpl & | Reset ()
| Reset all bits.
constexpr Timpl & | Reset (Tvalue_type value)
| Reset the value-th bit.
constexpr Timpl & | Reset (const Timpl &other)
| Reset values from another bitset.
constexpr Timpl & | Flip (Tvalue_type value)
| Flip the value-th bit.
constexpr Timpl & | Flip (const Timpl &other)
| Flip values from another bitset.
constexpr bool | Test (Tvalue_type value) const
| Test if the value-th bit is set.
constexpr bool | All (const Timpl &other) const
| Test if all of the values are set.
constexpr bool | All () const
| Test if all of the values are set.
constexpr bool | Any (const Timpl &other) const
| Test if any of the given values are set.
constexpr bool | Any () const
| Test if any of the values are set.
constexpr bool | None () const
| Test if none of the values are set.
constexpr Timpl & | operator|= (const Timpl &other)
constexpr Timpl | operator| (const Timpl &other) const
constexpr Timpl & | operator&= (const Timpl &other)
constexpr Timpl | operator& (const Timpl &other) const
constexpr Tstorage | base () const noexcept
| Retrieve the raw value behind this bit set.
constexpr bool | IsValid () const
| Test that the raw value of this bit set is valid.
uint | Count () const
| Count the number of set bits.
std::optional< Tvalue_type > | GetNthSetBit (uint n) const
| Get the value of the Nth set bit.
auto | begin () const
auto | end () const

## Static Public Member Functions
static constexpr size_t | DecayValueType (const BaseClass::ValueType &value)

## Private Types
using | BaseClass = BaseBitSet< EnumBitSet< Tenum, Tstorage, Tend_value >, Tenum, Tstorage, EnumBitSetMask< Tstorage, Tenum, Tend_value >::value >

## Additional Inherited Members
Static Public Attributes inherited from BaseBitSet< Timpl, Tvalue_type, Tstorage, Tmask >
static constexpr Tstorage | MASK = Tmask
| Mask of valid values.

## Detailed Description

template<typename Tenum, typename Tstorage, Tenum Tend_value = Tenum{std::numeric_limits<Tstorage>::digits}>
class EnumBitSet< Tenum, Tstorage, Tend_value >

Enum-as-bit-set wrapper.

Allows wrapping enum values as a bit set. Methods are loosely modelled on std::bitset.

Note
  Only set Tend_value if the bitset needs to be automatically masked to valid values.

Template Parameters

  Tenum | Enum values to wrap.
  Tstorage | Storage type required to hold eenum values.
  Tend_value | Last valid value + 1.

Definition at line 177 of file enum_type.hpp.

## Member Typedef Documentation

## ◆ BaseClass

template<typename Tenum , typename Tstorage , Tenum Tend_value = Tenum{std::numeric_limits<Tstorage>::digits}>

using EnumBitSet< Tenum, Tstorage, Tend_value >::BaseClass = BaseBitSet<EnumBitSet<Tenum, Tstorage, Tend_value>, Tenum, Tstorage, EnumBitSetMask<Tstorage, Tenum, Tend_value>::value>
| private

Definition at line 178 of file enum_type.hpp.

## ◆ EnumType

template<typename Tenum , typename Tstorage , Tenum Tend_value = Tenum{std::numeric_limits<Tstorage>::digits}>

using EnumBitSet< Tenum, Tstorage, Tend_value >::EnumType = BaseClass::ValueType

Definition at line 180 of file enum_type.hpp.

## Constructor & Destructor Documentation

## ◆ EnumBitSet() [1/4]

template<typename Tenum , typename Tstorage , Tenum Tend_value = Tenum{std::numeric_limits<Tstorage>::digits}>

constexpr EnumBitSet< Tenum, Tstorage, Tend_value >::EnumBitSet | ( |  | ) |
| inlineconstexpr

Definition at line 182 of file enum_type.hpp.

## ◆ EnumBitSet() [2/4]

template<typename Tenum , typename Tstorage , Tenum Tend_value = Tenum{std::numeric_limits<Tstorage>::digits}>

constexpr EnumBitSet< Tenum, Tstorage, Tend_value >::EnumBitSet | ( | Tenum | value | ) |
| inlineconstexpr

Definition at line 183 of file enum_type.hpp.

## ◆ EnumBitSet() [3/4]

template<typename Tenum , typename Tstorage , Tenum Tend_value = Tenum{std::numeric_limits<Tstorage>::digits}>

constexpr EnumBitSet< Tenum, Tstorage, Tend_value >::EnumBitSet | ( | Tstorage | data | ) |
| inlineexplicitconstexpr

Definition at line 184 of file enum_type.hpp.

## ◆ EnumBitSet() [4/4]

template<typename Tenum , typename Tstorage , Tenum Tend_value = Tenum{std::numeric_limits<Tstorage>::digits}>

constexpr EnumBitSet< Tenum, Tstorage, Tend_value >::EnumBitSet | ( | std::initializer_list< const Tenum > | values | ) |
| inlineconstexpr

Construct an EnumBitSet from a list of enum values.

Parameters

  values | List of enum values.

Definition at line 190 of file enum_type.hpp.

References BaseBitSet< Timpl, Tvalue_type, Tstorage, Tmask >::Set().

## Member Function Documentation

## ◆ DecayValueType()

template<typename Tenum , typename Tstorage , Tenum Tend_value = Tenum{std::numeric_limits<Tstorage>::digits}>

static constexpr size_t EnumBitSet< Tenum, Tstorage, Tend_value >::DecayValueType | ( | const BaseClass::ValueType & | value | ) |
| inlinestaticconstexpr

Definition at line 199 of file enum_type.hpp.

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

- src/core/enum_type.hpp