41#include "enumInterface.hpp"
63 template<
typename T_Enum>
69 using UnderlyingEnumType =
typename std::underlying_type<Enum>::type;
70 using Bitset = std::bitset<static_cast<UnderlyingEnumType>(Enum::MaxElement)>;
72 static UnderlyingEnumType
constexpr ALL_VALUE = (1 <<
static_cast<UnderlyingEnumType
>(Enum::MaxElement)) - 1;
77 return static_cast<UnderlyingEnumType
>(v);
94 return bitset.test(get_value(pos));
99 bitset.
reset(get_value(pos));
105 bitset.
flip(get_value(pos));
112 bitset &= Bitset(ALL_VALUE);
118 bitset.
set(get_value(pos));
152 return bitset != o.bitset;
162 return bitset == o.bitset;
172 return this->bitset.any();
192 template<
typename Enum>
201 template<
typename Enum>
210 template<
typename Enum>
216 template<
typename Enum>
225 template<
typename Enum>
234 template<
typename Enum>
240 template<
typename Enum>
246 template<
typename Enum>
252 template<
typename Out,
typename Enum>
#define CODI_INLINE
See codi::Config::ForcedInlines.
Definition config.h:457
CoDiPack - Code Differentiation Package.
Definition codi.hpp:90
EnumBitset< Enum > operator|(EnumBitset< Enum > const &a, EnumBitset< Enum > const &b)
Or operation of two bitsets.
Definition enumBitset.hpp:193
bool operator==(Enum a, EnumBitset< Enum > const &b)
Equal comparison for an enum and a bitset.
Definition enumBitset.hpp:247
ExpressionTraits::EnableIfExpression< Expr, std::ostream > & operator<<(std::ostream &out, Expr const &v)
Write the primal value to the stream.
Definition expressionInterface.hpp:129
bool operator!=(Enum a, EnumBitset< Enum > const &b)
Not equal comparison for an enum and a bitset.
Definition enumBitset.hpp:241
EnumBitset< Enum > operator&(EnumBitset< Enum > const &a, EnumBitset< Enum > const &b)
And operation of two bitsets.
Definition enumBitset.hpp:217
A bitset with enum items as flags.
Definition enumBitset.hpp:64
EnumBitset & operator&=(EnumBitset const &o)
And operation of two bitsets.
Definition enumBitset.hpp:140
EnumBitset & set(Enum pos)
Set the bit for the enum to true.
Definition enumBitset.hpp:117
EnumBitset & operator|=(Enum const &pos)
Or operation of the bitset and an enum.
Definition enumBitset.hpp:135
EnumBitset & reset(Enum pos)
Reset the bit for the enum to false.
Definition enumBitset.hpp:98
static constexpr EnumBitset NONE()
Constructor for a bitset with all values flagged as false.
Definition enumBitset.hpp:186
EnumBitset()=default
Constructor all false.
static constexpr EnumBitset ALL()
Constructor for a bitset with all values flagged as true.
Definition enumBitset.hpp:181
EnumBitset & flip()
Flip all bits.
Definition enumBitset.hpp:110
bool operator!=(EnumBitset const &o) const
Not equal operation for two bitsets.
Definition enumBitset.hpp:151
bool test(Enum pos) const
Test if the bit for the enum is set.
Definition enumBitset.hpp:93
T_Enum Enum
See EnumBitset.
Definition enumBitset.hpp:66
EnumBitset & reset()
Reset all bits to false.
Definition enumBitset.hpp:123
bool operator==(Enum const &pos) const
Equal operation for a bitset and an enum.
Definition enumBitset.hpp:166
EnumBitset(Enum pos)
Constructor which sets one bit to true.
Definition enumBitset.hpp:88
EnumBitset & operator|=(EnumBitset const &o)
Or operation of two bitsets.
Definition enumBitset.hpp:129
bool operator==(EnumBitset const &o) const
Equal operation for two bitsets.
Definition enumBitset.hpp:161
Bitset getData() const
Get the underlying bitset.
Definition enumBitset.hpp:176
EnumBitset & flip(Enum pos)
Flip the bit for the enum.
Definition enumBitset.hpp:104
EnumBitset & operator&=(Enum const &pos)
And operation of the bitsets and and enum.
Definition enumBitset.hpp:146
bool any()
Conversion to boolean.
Definition enumBitset.hpp:171
bool operator!=(Enum const &pos) const
Not equal operation for a bitset and an enum.
Definition enumBitset.hpp:156