MySQL 8.0.39
Source Code Documentation
|
a type-safe flags type. More...
#include <flags.h>
Public Types | |
using | enum_type = std::decay_t< E > |
underlying integer type of the enum_type. More... | |
using | underlying_type = std::underlying_type_t< enum_type > |
implementation type of the underlying type. More... | |
using | impl_type = std::make_unsigned_t< underlying_type > |
using | size_type = std::size_t |
Public Member Functions | |
constexpr | flags ()=default |
default constructor. More... | |
constexpr | flags (const flags &other)=default |
copy constructor. More... | |
constexpr | flags (flags &&other)=default |
move constructor More... | |
constexpr flags & | operator= (const flags &other)=default |
copy assignment More... | |
constexpr flags & | operator= (flags &&other)=default |
move assignment More... | |
constexpr | flags (enum_type v) |
converting constructor from enum_type. More... | |
constexpr | operator bool () const noexcept |
check if any bit is set. More... | |
constexpr bool | operator! () const noexcept |
check if no bit is set. More... | |
constexpr flags | operator~ () const noexcept |
negation of all bits. More... | |
constexpr flags & | operator|= (const flags &other) noexcept |
bit-or. More... | |
constexpr flags & | operator&= (const flags &other) noexcept |
bit-and. More... | |
constexpr flags & | operator^= (const flags &other) noexcept |
bit-xor. More... | |
constexpr void | underlying_value (underlying_type v) noexcept |
set underlying value. More... | |
constexpr underlying_type | underlying_value () const noexcept |
get underlying value. More... | |
constexpr size_type | count () const noexcept |
count bits set to true. More... | |
constexpr size_type | size () const noexcept |
returns number of bits the flag-type can hold. More... | |
constexpr void | reset () |
reset all flags to 0. More... | |
Private Member Functions | |
constexpr | flags (impl_type v) noexcept |
Private Attributes | |
impl_type | v_ {} |
Friends | |
constexpr friend flags | operator& (flags a, flags b) noexcept |
bit-and. More... | |
constexpr friend flags | operator| (flags a, flags b) noexcept |
bit-or. More... | |
constexpr friend flags | operator^ (flags a, flags b) noexcept |
bit-xor. More... | |
a type-safe flags type.
Using flags in the in C++ isn't very ergonimic:
For ease of use it should be possible to have a flags-type which allows the type-safe operations:
E | a scoped enum that is tagged with stdx::is_flags. |
using stdx::flags< E >::enum_type = std::decay_t<E> |
underlying integer type of the enum_type.
using stdx::flags< E >::impl_type = std::make_unsigned_t<underlying_type> |
using stdx::flags< E >::size_type = std::size_t |
using stdx::flags< E >::underlying_type = std::underlying_type_t<enum_type> |
implementation type of the underlying type.
|
constexprdefault |
default constructor.
initializes underlying_value to 0 (no-bits-set).
|
constexprdefault |
copy constructor.
|
constexprdefault |
move constructor
|
inlineconstexpr |
converting constructor from enum_type.
|
inlineexplicitconstexprprivatenoexcept |
|
inlineconstexprnoexcept |
count bits set to true.
|
inlineconstexprnoexcept |
check if any bit is set.
true | at least one bit is set. |
false | no bit is set. |
|
inlineconstexprnoexcept |
check if no bit is set.
true | no bit is set. |
false | at least one bit is set. |
|
inlineconstexprnoexcept |
bit-and.
flags &= flags.
|
constexprdefault |
copy assignment
|
constexprdefault |
move assignment
|
inlineconstexprnoexcept |
bit-xor.
flag ^= flag
|
inlineconstexprnoexcept |
bit-or.
flags |= flags.
|
inlineconstexprnoexcept |
negation of all bits.
~flags -> flags.
|
inlineconstexpr |
reset all flags to 0.
|
inlineconstexprnoexcept |
returns number of bits the flag-type can hold.
|
inlineconstexprnoexcept |
get underlying value.
|
inlineconstexprnoexcept |
set underlying value.
v | underlying value to set. |
bit-and.
flags & flags -> flags
bit-xor.
flags ^ flags -> flags
bit-or.
flags | flags -> flags
|
private |