7 class U = std::underlying_type_t<E>>
14 static_assert(std::is_enum_v<E>,
"EnumSet<E, ...> must be an enum");
15 static_assert(std::is_integral_v<U>,
"EnumSet<..., U> must be an integral");
23 _impl(static_cast<U>(a_rhs.
get()))
26 template <
class... Args>
27 constexpr EnumSet(Args... a_values)
noexcept
28 requires(std::same_as<Args, E>&&...) :
29 _impl((
static_cast<U
>(a_values) | ...))
40 _impl =
static_cast<U
>(a_rhs.get());
45 _impl =
static_cast<U
>(a_value);
50 [[nodiscard]]
explicit constexpr operator bool() const noexcept {
return _impl !=
static_cast<U
>(0); }
52 [[nodiscard]]
constexpr E
operator*() const noexcept {
return get(); }
53 [[nodiscard]]
constexpr E
get() const noexcept {
return static_cast<E
>(_impl); }
54 [[nodiscard]]
constexpr U
underlying() const noexcept {
return _impl; }
57 template <
class... Args>
59 requires(std::same_as<Args, E>&&...)
61 _impl |= (
static_cast<U
>(a_args) | ...);
65 template <
class... Args>
66 constexpr EnumSet&
set(
bool a_set, Args... a_args)
noexcept
67 requires(std::same_as<Args, E>&&...)
70 _impl |= (
static_cast<U
>(a_args) | ...);
72 _impl &= ~(
static_cast<U
>(a_args) | ...);
77 template <
class... Args>
79 requires(std::same_as<Args, E>&&...)
81 _impl &= ~(
static_cast<U
>(a_args) | ...);
91 template <
class... Args>
92 [[nodiscard]]
constexpr bool any(Args... a_args)
const noexcept
93 requires(std::same_as<Args, E>&&...)
95 return (_impl & (
static_cast<U
>(a_args) | ...)) !=
static_cast<U
>(0);
98 template <
class... Args>
99 [[nodiscard]]
constexpr bool all(Args... a_args)
const noexcept
100 requires(std::same_as<Args, E>&&...)
102 return (_impl & (
static_cast<U
>(a_args) | ...)) == (
static_cast<U
>(a_args) | ...);
105 template <
class... Args>
106 [[nodiscard]]
constexpr bool none(Args... a_args)
const noexcept
107 requires(std::same_as<Args, E>&&...)
109 return (_impl & (
static_cast<U
>(a_args) | ...)) ==
static_cast<U
>(0);
114 friend constexpr bool operator==(
EnumSet a_lhs, E a_rhs)
noexcept {
return a_lhs.underlying() ==
static_cast<U
>(a_rhs); }
115 friend constexpr bool operator==(E a_lhs,
EnumSet a_rhs)
noexcept {
return static_cast<U
>(a_lhs) == a_rhs.underlying(); }
117 friend constexpr std::strong_ordering
operator<=>(
EnumSet a_lhs,
EnumSet a_rhs)
noexcept {
return a_lhs.underlying() <=> a_rhs.underlying(); }
118 friend constexpr std::strong_ordering
operator<=>(
EnumSet a_lhs, E a_rhs)
noexcept {
return a_lhs.underlying() <=>
static_cast<U
>(a_rhs); }
119 friend constexpr std::strong_ordering
operator<=>(E a_lhs,
EnumSet a_rhs)
noexcept {
return static_cast<U
>(a_lhs) <=> a_rhs.underlying(); }
122 friend constexpr EnumSet operator&(
EnumSet a_lhs, E a_rhs)
noexcept {
return static_cast<E
>(a_lhs.underlying() &
static_cast<U
>(a_rhs)); }
123 friend constexpr EnumSet operator&(E a_lhs,
EnumSet a_rhs)
noexcept {
return static_cast<E
>(
static_cast<U
>(a_lhs) & a_rhs.underlying()); }
129 friend constexpr EnumSet operator|(
EnumSet a_lhs, E a_rhs)
noexcept {
return static_cast<E
>(a_lhs.underlying() |
static_cast<U
>(a_rhs)); }
130 friend constexpr EnumSet operator|(E a_lhs,
EnumSet a_rhs)
noexcept {
return static_cast<E
>(
static_cast<U
>(a_lhs) | a_rhs.underlying()); }
136 friend constexpr EnumSet operator^(
EnumSet a_lhs, E a_rhs)
noexcept {
return static_cast<E
>(a_lhs.underlying() ^
static_cast<U
>(a_rhs)); }
137 friend constexpr EnumSet operator^(E a_lhs,
EnumSet a_rhs)
noexcept {
return static_cast<E
>(
static_cast<U
>(a_lhs) ^ a_rhs.underlying()); }
143 friend constexpr EnumSet operator+(
EnumSet a_lhs, E a_rhs)
noexcept {
return static_cast<E
>(a_lhs.underlying() +
static_cast<U
>(a_rhs)); }
144 friend constexpr EnumSet operator+(E a_lhs,
EnumSet a_rhs)
noexcept {
return static_cast<E
>(
static_cast<U
>(a_lhs) + a_rhs.underlying()); }
150 friend constexpr EnumSet operator-(
EnumSet a_lhs, E a_rhs)
noexcept {
return static_cast<E
>(a_lhs.underlying() -
static_cast<U
>(a_rhs)); }
151 friend constexpr EnumSet operator-(E a_lhs,
EnumSet a_rhs)
noexcept {
return static_cast<E
>(
static_cast<U
>(a_lhs) - a_rhs.underlying()); }
157 friend constexpr EnumSet operator<<(
EnumSet a_lhs, E a_rhs)
noexcept {
return static_cast<E
>(a_lhs.underlying() <<
static_cast<U
>(a_rhs)); }
158 friend constexpr EnumSet operator<<(E a_lhs,
EnumSet a_rhs)
noexcept {
return static_cast<E
>(
static_cast<U
>(a_lhs) << a_rhs.underlying()); }
164 friend constexpr EnumSet operator>>(
EnumSet a_lhs, E a_rhs)
noexcept {
return static_cast<E
>(a_lhs.underlying() >>
static_cast<U
>(a_rhs)); }
165 friend constexpr EnumSet operator>>(E a_lhs,
EnumSet a_rhs)
noexcept {
return static_cast<E
>(
static_cast<U
>(a_lhs) >> a_rhs.underlying()); }
176 template <
class... Args>
178 std::common_type_t<Args...>,
179 std::underlying_type_t<
180 std::common_type_t<Args...>>>;
friend constexpr EnumSet & operator&=(EnumSet &a_lhs, EnumSet a_rhs) noexcept
Definition EnumSet.h:125
constexpr EnumSet() noexcept=default
constexpr bool any(Args... a_args) const noexcept
Definition EnumSet.h:92
constexpr U underlying() const noexcept
Definition EnumSet.h:54
constexpr EnumSet & reset(Args... a_args) noexcept
Definition EnumSet.h:78
friend constexpr EnumSet operator&(EnumSet a_lhs, E a_rhs) noexcept
Definition EnumSet.h:122
friend constexpr EnumSet operator|(EnumSet a_lhs, EnumSet a_rhs) noexcept
Definition EnumSet.h:128
friend constexpr EnumSet operator|(E a_lhs, EnumSet a_rhs) noexcept
Definition EnumSet.h:130
friend constexpr EnumSet & operator&=(EnumSet &a_lhs, E a_rhs) noexcept
Definition EnumSet.h:126
constexpr E get() const noexcept
Definition EnumSet.h:53
constexpr EnumSet & reset() noexcept
Definition EnumSet.h:85
friend constexpr EnumSet operator>>(EnumSet a_lhs, E a_rhs) noexcept
Definition EnumSet.h:164
friend constexpr EnumSet & operator-=(EnumSet &a_lhs, EnumSet a_rhs) noexcept
Definition EnumSet.h:153
friend constexpr std::strong_ordering operator<=>(E a_lhs, EnumSet a_rhs) noexcept
Definition EnumSet.h:119
friend constexpr EnumSet operator>>(E a_lhs, EnumSet a_rhs) noexcept
Definition EnumSet.h:165
friend constexpr EnumSet operator<<(E a_lhs, EnumSet a_rhs) noexcept
Definition EnumSet.h:158
friend constexpr EnumSet & operator>>=(EnumSet &a_lhs, E a_rhs) noexcept
Definition EnumSet.h:168
constexpr bool none(Args... a_args) const noexcept
Definition EnumSet.h:106
constexpr bool all(Args... a_args) const noexcept
Definition EnumSet.h:99
friend constexpr EnumSet & operator+=(EnumSet &a_lhs, EnumSet a_rhs) noexcept
Definition EnumSet.h:146
friend constexpr EnumSet operator^(EnumSet a_lhs, EnumSet a_rhs) noexcept
Definition EnumSet.h:135
friend constexpr EnumSet & operator-=(EnumSet &a_lhs, E a_rhs) noexcept
Definition EnumSet.h:154
friend constexpr EnumSet operator<<(EnumSet a_lhs, EnumSet a_rhs) noexcept
Definition EnumSet.h:156
friend constexpr EnumSet operator+(E a_lhs, EnumSet a_rhs) noexcept
Definition EnumSet.h:144
friend constexpr EnumSet & operator|=(EnumSet &a_lhs, E a_rhs) noexcept
Definition EnumSet.h:133
friend constexpr EnumSet operator+(EnumSet a_lhs, EnumSet a_rhs) noexcept
Definition EnumSet.h:142
friend constexpr EnumSet & operator~(EnumSet &a_lhs) noexcept
Definition EnumSet.h:170
constexpr EnumSet & set(Args... a_args) noexcept
Definition EnumSet.h:58
constexpr EnumSet & set(bool a_set, Args... a_args) noexcept
Definition EnumSet.h:66
friend constexpr EnumSet & operator<<=(EnumSet &a_lhs, E a_rhs) noexcept
Definition EnumSet.h:161
friend constexpr EnumSet operator-(EnumSet a_lhs, E a_rhs) noexcept
Definition EnumSet.h:150
friend constexpr EnumSet operator^(E a_lhs, EnumSet a_rhs) noexcept
Definition EnumSet.h:137
friend constexpr EnumSet operator&(EnumSet a_lhs, EnumSet a_rhs) noexcept
Definition EnumSet.h:121
constexpr EnumSet(Args... a_values) noexcept
Definition EnumSet.h:27
friend constexpr EnumSet operator^(EnumSet a_lhs, E a_rhs) noexcept
Definition EnumSet.h:136
friend constexpr bool operator==(EnumSet a_lhs, E a_rhs) noexcept
Definition EnumSet.h:114
U underlying_type
Definition EnumSet.h:12
~EnumSet() noexcept=default
friend constexpr bool operator==(EnumSet a_lhs, EnumSet a_rhs) noexcept
Definition EnumSet.h:113
friend constexpr std::strong_ordering operator<=>(EnumSet a_lhs, EnumSet a_rhs) noexcept
Definition EnumSet.h:117
friend constexpr EnumSet & operator>>=(EnumSet &a_lhs, EnumSet a_rhs) noexcept
Definition EnumSet.h:167
friend constexpr EnumSet & operator+=(EnumSet &a_lhs, E a_rhs) noexcept
Definition EnumSet.h:147
friend constexpr EnumSet operator&(E a_lhs, EnumSet a_rhs) noexcept
Definition EnumSet.h:123
friend constexpr EnumSet operator>>(EnumSet a_lhs, EnumSet a_rhs) noexcept
Definition EnumSet.h:163
friend constexpr EnumSet operator-(EnumSet a_lhs, EnumSet a_rhs) noexcept
Definition EnumSet.h:149
friend constexpr EnumSet operator+(EnumSet a_lhs, E a_rhs) noexcept
Definition EnumSet.h:143
constexpr EnumSet & operator=(E a_value) noexcept
Definition EnumSet.h:43
friend constexpr EnumSet & operator^=(EnumSet &a_lhs, E a_rhs) noexcept
Definition EnumSet.h:140
friend constexpr EnumSet operator<<(EnumSet a_lhs, E a_rhs) noexcept
Definition EnumSet.h:157
constexpr E operator*() const noexcept
Definition EnumSet.h:52
friend constexpr EnumSet & operator|=(EnumSet &a_lhs, EnumSet a_rhs) noexcept
Definition EnumSet.h:132
friend constexpr EnumSet & operator^=(EnumSet &a_lhs, EnumSet a_rhs) noexcept
Definition EnumSet.h:139
friend constexpr std::strong_ordering operator<=>(EnumSet a_lhs, E a_rhs) noexcept
Definition EnumSet.h:118
friend constexpr EnumSet operator-(E a_lhs, EnumSet a_rhs) noexcept
Definition EnumSet.h:151
friend constexpr EnumSet operator|(EnumSet a_lhs, E a_rhs) noexcept
Definition EnumSet.h:129
friend constexpr bool operator==(E a_lhs, EnumSet a_rhs) noexcept
Definition EnumSet.h:115
friend constexpr EnumSet & operator<<=(EnumSet &a_lhs, EnumSet a_rhs) noexcept
Definition EnumSet.h:160
E enum_type
Definition EnumSet.h:11
Definition BSDirectInputManager.h:8