26#ifndef MYSQL_HARNESS_STDX_FLAGS_INCLUDED
27#define MYSQL_HARNESS_STDX_FLAGS_INCLUDED
37template <
class E,
class Enabler =
void>
117 static_assert(stdx::is_scoped_enum_v<E>,
118 "flags<E>, E must be a scoped enum type");
119 static_assert(is_flags_v<E>,
120 "flags<E>, E must be declared as flags-type via:"
121 "namespace stdx { template<> struct is_flags<...> : "
122 "std::true_type {};} ");
129 using impl_type = std::make_unsigned_t<underlying_type>;
156 constexpr operator bool() const noexcept {
return v_ != 0; }
254 return std::popcount(
v_);
a type-safe flags type.
Definition: flags.h:115
constexpr flags & operator&=(const flags &other) noexcept
bit-and.
Definition: flags.h:190
std::make_unsigned_t< underlying_type > impl_type
Definition: flags.h:129
constexpr size_type size() const noexcept
returns number of bits the flag-type can hold.
Definition: flags.h:264
constexpr flags & operator=(flags &&other)=default
move assignment
constexpr flags(const flags &other)=default
copy constructor.
constexpr void underlying_value(underlying_type v) noexcept
set underlying value.
Definition: flags.h:237
constexpr friend flags operator^(flags a, flags b) noexcept
bit-xor.
Definition: flags.h:228
constexpr flags & operator=(const flags &other)=default
copy assignment
constexpr flags(flags &&other)=default
move constructor
constexpr bool operator!() const noexcept
check if no bit is set.
Definition: flags.h:164
std::decay_t< E > enum_type
underlying integer type of the enum_type.
Definition: flags.h:126
impl_type v_
Definition: flags.h:276
constexpr void reset()
reset all flags to 0.
Definition: flags.h:271
constexpr flags(enum_type v)
converting constructor from enum_type.
Definition: flags.h:148
constexpr friend flags operator&(flags a, flags b) noexcept
bit-and.
Definition: flags.h:210
std::size_t size_type
Definition: flags.h:130
constexpr size_type count() const noexcept
count bits set to true.
Definition: flags.h:253
constexpr flags & operator^=(const flags &other) noexcept
bit-xor.
Definition: flags.h:200
constexpr flags()=default
default constructor.
constexpr underlying_type underlying_value() const noexcept
get underlying value.
Definition: flags.h:244
std::underlying_type_t< enum_type > underlying_type
implementation type of the underlying type.
Definition: flags.h:128
constexpr flags operator~() const noexcept
negation of all bits.
Definition: flags.h:171
constexpr flags(impl_type v) noexcept
Definition: flags.h:274
constexpr friend flags operator|(flags a, flags b) noexcept
bit-or.
Definition: flags.h:219
constexpr flags & operator|=(const flags &other) noexcept
bit-or.
Definition: flags.h:180
constexpr auto operator|(E e1, E e2) noexcept -> std::enable_if_t< stdx::is_flags< E >::value, stdx::flags< E > >
bit-or.
Definition: flags.h:289
constexpr auto operator^(E e1, E e2) noexcept -> std::enable_if_t< stdx::is_flags< E >::value, stdx::flags< E > >
bit-xor.
Definition: flags.h:315
constexpr auto operator&(E e1, E e2) noexcept -> std::enable_if_t< stdx::is_flags< E >::value, stdx::flags< E > >
bit-and.
Definition: flags.h:302
constexpr bool is_flags_v
Definition: flags.h:41