7 #ifndef NAZARA_FLAGS_HPP 8 #define NAZARA_FLAGS_HPP 10 #include <Nazara/Prerequesites.hpp> 11 #include <type_traits> 19 static constexpr
bool value =
false;
20 static constexpr
int max = 0;
26 static_assert(std::is_enum<E>::value,
"Type must be an enumeration");
27 static_assert(EnumAsFlags<E>::value,
"Enum has not been enabled as flags by an EnumAsFlags specialization");
30 using BitField =
typename std::conditional<(EnumAsFlags<E>::max > 32), UInt64, UInt32>::type;
32 constexpr
Flags(BitField value = 0);
33 constexpr Flags(E enumVal);
35 explicit constexpr
operator bool()
const;
36 explicit constexpr
operator BitField()
const;
38 constexpr Flags operator~()
const;
39 constexpr Flags
operator&(
const Flags& rhs)
const;
40 constexpr Flags
operator|(
const Flags& rhs)
const;
41 constexpr Flags
operator^(
const Flags& rhs)
const;
43 constexpr
bool operator==(
const Flags& rhs)
const;
44 constexpr
bool operator!=(
const Flags& rhs)
const;
46 Flags& operator|=(
const Flags& rhs);
47 Flags& operator&=(
const Flags& rhs);
48 Flags& operator^=(
const Flags& rhs);
50 static constexpr BitField GetFlagValue(E enumValue);
52 static constexpr BitField ValueMask = ((BitField(1) << (EnumAsFlags<E>::max + 1)) - 1);
59 namespace FlagsOperators
61 template<
typename E> constexpr std::enable_if_t<EnumAsFlags<E>::value,
Flags<E>> operator~(E lhs);
62 template<
typename E> constexpr std::enable_if_t<EnumAsFlags<E>::value,
Flags<E>>
operator|(E lhs, E rhs);
63 template<
typename E> constexpr std::enable_if_t<EnumAsFlags<E>::value,
Flags<E>>
operator&(E lhs, E rhs);
64 template<
typename E> constexpr std::enable_if_t<EnumAsFlags<E>::value,
Flags<E>>
operator^(E lhs, E rhs);
67 using namespace FlagsOperators;
72 #include <Nazara/Core/Flags.inl> 74 #endif // NAZARA_FLAGS_HPP TODO: Inherit SoundEmitter from Node.
Definition: Algorithm.hpp:12
Bitset< Block, Allocator > operator^(const Bitset< Block, Allocator > &lhs, const Bitset< Block, Allocator > &rhs)
Performs the operator "XOR" between two bitsets.
Definition: Bitset.inl:1628
bool operator!=(const Bitset< Block, Allocator > &lhs, const Nz::Bitset< Block, Allocator > &rhs)
Compares two bitsets.
Definition: Bitset.inl:1503
Bitset< Block, Allocator > operator &(const Bitset< Block, Allocator > &lhs, const Bitset< Block, Allocator > &rhs)
Performs the operator "AND" between two bitsets.
Definition: Bitset.inl:1594
Core class used to combine enumeration values into flags bitfield.
Definition: Flags.hpp:24
Bitset< Block, Allocator > operator|(const Bitset< Block, Allocator > &lhs, const Bitset< Block, Allocator > &rhs)
Performs the operator "OR" between two bitsets.
Definition: Bitset.inl:1611
bool operator==(const Bitset< Block, Allocator > &lhs, const Nz::Bitset< Block, Allocator > &rhs)
Compares two bitsets.
Definition: Bitset.inl:1469