6#include <initializer_list>
15template<
typename Value,
typename Input = Value>
18 static_assert(std::is_integral_v<Value>);
19 static_assert(std::is_integral_v<Input> || std::is_enum_v<Input>);
21 static_assert(
sizeof(Value) >=
sizeof(Input),
22 "Input type may overflow Value type.");
25 using FlagsSet = std::initializer_list<Input>;
34 explicit constexpr TBitFlags(
const FlagsSet& flagsSet);
38 explicit constexpr TBitFlags(Input flagsSet);
42 template<
typename OtherInput>
65 constexpr bool hasNone(
const FlagsSet& flagsSet)
const;
69 constexpr bool hasAny(
const FlagsSet& flagsSet)
const;
73 constexpr bool hasAll(
const FlagsSet& flagsSet)
const;
77 constexpr bool hasExactly(
const FlagsSet& flagsSet)
const;
81 constexpr bool hasNone(Input flagsSet)
const;
85 constexpr bool hasAny(Input flagsSet)
const;
89 constexpr bool hasAll(Input flagsSet)
const;
93 constexpr bool hasExactly(Input flagsSet)
const;
99 constexpr bool has(Input singleFlag)
const;
105 constexpr bool hasNo(Input singleFlag)
const;
109 constexpr bool isEmpty()
const;
115 constexpr Value
get()
const;
128 return static_cast<Input
>(m_bits);
134 static constexpr Value collectFlags(
const FlagsSet& flagsSet);
139template<CEnum EnumType>
146#define PH_DEFINE_INLINE_ENUM_FLAG_OPERATORS(EnumType)\
147 static_assert(::ph::CEnum<EnumType>, #EnumType " must be an enum type");\
149 inline constexpr EnumType operator | (const EnumType lhs, const EnumType rhs)\
151 return ::ph::TEnumFlags<EnumType>({lhs, rhs}).getEnum();\
154 inline constexpr EnumType operator & (const EnumType lhs, const EnumType rhs)\
156 return ::ph::TEnumFlags<EnumType>({lhs}).intersectWith({rhs}).getEnum();\
Manipulate a value type where each bit is a binary flag.
Definition TBitFlags.h:17
constexpr bool hasExactly(const FlagsSet &flagsSet) const
Checks whether this instance contains exactly the specified flags. No more, no less.
Definition TBitFlags.ipp:99
constexpr bool has(Input singleFlag) const
Checks whether this single flag is fully contained.
Definition TBitFlags.ipp:133
constexpr bool isEmpty() const
Checks whether this instance contains no flags.
Definition TBitFlags.ipp:145
constexpr TBitFlags & set(const FlagsSet &flagsSet)
Definition TBitFlags.ipp:54
constexpr TBitFlags & intersectWith(const FlagsSet &flagsSet)
Intersects this instance with the specified flags.
Definition TBitFlags.ipp:46
constexpr TBitFlags & turnOff(const FlagsSet &flagsSet)
Definition TBitFlags.ipp:73
constexpr bool hasAny(const FlagsSet &flagsSet) const
Checks whether this instance contains at least one of the specified flags.
Definition TBitFlags.ipp:87
constexpr bool hasNo(Input singleFlag) const
Checks whether this single flag is fully absent.
Definition TBitFlags.ipp:139
constexpr bool hasNone(const FlagsSet &flagsSet) const
Checks whether this instance contains no specified flags.
Definition TBitFlags.ipp:81
constexpr TBitFlags()
Creates an instance with no flags.
Definition TBitFlags.ipp:9
constexpr Value get() const
Get the value representing current flags.
Definition TBitFlags.ipp:157
constexpr bool hasAll(const FlagsSet &flagsSet) const
Checks whether this instance contains all of the specified flags.
Definition TBitFlags.ipp:93
constexpr TBitFlags & turnOn(const FlagsSet &flagsSet)
Enable/disable specified flags.
Definition TBitFlags.ipp:67
constexpr TBitFlags & unionWith(const FlagsSet &flagsSet)
Unions specified flags into this instance.
Definition TBitFlags.ipp:30
constexpr Input getEnum() const
Get the enum representing current flags. This method is only defined for enum flags.
Definition TBitFlags.h:125
constexpr bool isEqual(const TBitFlags &other) const
Definition TBitFlags.ipp:151
Whether the type is a scoped/unscoped enum.
Definition traits.h:98
class ph::math::TBvhSimdComputingContext sizeof(float32) *BATCH_SIZE >
Definition TBvhSimdComputingContext.h:341
The root for all renderer implementations.
Definition EEngineProject.h:6