wowlib
0.0.0
Read & write World of Warcraft client files — a C++26 core
Toggle main menu visibility
Loading...
Searching...
No Matches
flags.hpp
Go to the documentation of this file.
1
#pragma once
2
14
15
#include <type_traits>
16
#include <utility>
17
18
namespace
wowlib::formats
{
24
template
<
typename
E>
requires
std::is_scoped_enum_v<E>
25
[[nodiscard]]
constexpr
bool
26
hasFlag
(std::underlying_type_t<E> value, E flag) {
27
return
(value & std::to_underlying(flag)) == std::to_underlying(flag);
28
}
29
36
template
<
typename
E>
requires
std::is_scoped_enum_v<E>
37
[[nodiscard]]
constexpr
bool
hasFlag
(E value, E flag) {
38
return
(std::to_underlying(value) & std::to_underlying(flag)) ==
39
std::to_underlying(flag);
40
}
41
47
template
<
typename
E>
requires
std::is_scoped_enum_v<E>
48
constexpr
void
setFlag
(E& value, E flag,
bool
on =
true
) {
49
value =
static_cast<
E
>
(on
50
? std::to_underlying(value) |
51
std::to_underlying(flag)
52
: std::to_underlying(value) &
53
~std::to_underlying(flag));
54
}
55
}
wowlib::formats
Definition
adt.hpp:68
wowlib::formats::setFlag
constexpr void setFlag(E &value, E flag, bool on=true)
Set (or clear) flag bit flag in the enum-typed field value.
Definition
flags.hpp:48
wowlib::formats::hasFlag
constexpr bool hasFlag(std::underlying_type_t< E > value, E flag)
Whether flag bit flag is set in the raw binary value value.
Definition
flags.hpp:26
src
wowlib
formats
common
flags.hpp
Generated by
1.17.0