|
Typed flags
Type-safe and human-readable set of bool flags
|
#include <typed_flags.hpp>
Public Member Functions | |
Creation | |
| typed_flags ()=default | |
| template<typename... T> | |
| typed_flags (flag< T >...flags) noexcept | |
| typed_flags (unsigned long long data) noexcept | |
| template<class CharT > | |
| typed_flags (const CharT *str, typename std::basic_string< CharT >::size_type n=std::basic_string< CharT >::npos, CharT zero=CharT('0'), CharT one=CharT('1')) | |
Element access | |
| template<typename T > | |
| bool | test () const noexcept |
| template<typename... T> | |
| bool | none () const noexcept |
| template<typename... T> | |
| bool | any () const noexcept |
| template<typename... T> | |
| bool | all () const noexcept |
| template<typename... T> | |
| void | get (flag< T > &...flags) const noexcept |
Modifiers | |
| template<typename... T> | |
| void | set (flag< T >...flags) noexcept |
| template<typename... T> | |
| void | set (bool value=true) noexcept |
| template<typename... T> | |
| void | reset () noexcept |
| template<typename... T> | |
| void | flip () noexcept |
Conversions | |
| template<typename T > | |
| T | to_integral () const noexcept |
| template<class CharT = char, class Traits = std::char_traits<CharT>, class Allocator = std::allocator<CharT>> | |
| auto | to_string (CharT zero=CharT('0'), CharT one=CharT('1')) const |
Logical member operators | |
| bool | operator== (this_type const &other) const noexcept |
| bool | operator!= (this_type const &other) const noexcept |
Bitwise member operators | |
| this_type & | operator&= (this_type const &other) noexcept |
| this_type & | operator|= (this_type const &other) noexcept |
| this_type & | operator^= (this_type const &other) noexcept |
| this_type | operator~ () const noexcept |
Related Functions | |
(Note that these are not member functions.) | |
Bitwise non-member operators | |
| template<typename... Args> | |
| typed_flags< Args... > | operator& (typed_flags< Args... > const &lhs, typed_flags< Args... > const &rhs) |
| template<typename... Args> | |
| typed_flags< Args... > | operator| (typed_flags< Args... > const &lhs, typed_flags< Args... > const &rhs) |
| template<typename... Args> | |
| typed_flags< Args... > | operator^ (typed_flags< Args... > const &lhs, typed_flags< Args... > const &rhs) |
Capacity | |
| static constexpr size_t | length = sizeof...(Args) |
| constexpr size_t | size () const noexcept |
| template<typename T > | |
| static constexpr size_t | index () noexcept |
Type-safe flag container.
Templated frontend to raw bit storage. Allows type safe bit manipulations translating user defined types to corresponding indexes.
| Args... | user defined types. |
|
default |
Sets all flags to zero.
|
inlineexplicitnoexcept |
Sets concrete flags to corresponding values.
| flag<T>... | flag values. |
|
inlineexplicitnoexcept |
Loads flag values from integral number.
Least significant bit corresponds to the first parameter of the class template. Remaining flags are initialized to zeros.
| data | source integral number. |
|
inlineexplicit |
Loads flag values from characters.
Rightmost character corresponds to the first parameter of the class template. Remaining flags are initialized to zeros.
| str | string used to initialize flags. |
| n | number of characters to read from string (optional). |
| zero | character representing unset flag (optional). |
| one | character representing set flag (optional). |
| std::invalid_argument | if character is neither zero nor one. |
|
inlinenoexcept |
Checks that every specified flag is set.
| T... | flag types. |
|
inlinenoexcept |
Checks that at least one of specified flags is set.
| T... | flag types. |
|
inlinenoexcept |
Reverts specified flags i.e. zeros becomes ones and vice versa.
| T... | flag types. |
|
inlinenoexcept |
Extracts values of specified flags to variables.
| flag<T>&... | flag variables to store result. |
|
inlinestaticnoexcept |
Get index of specified flag.
| T | flag type. |
|
inlinenoexcept |
Checks that every specified flag is unset.
| T... | flag types. |
|
inlinenoexcept |
Unsets specified flags.
| T... | flag types. |
|
inlinenoexcept |
Sets specified flags from flag variables.
| flag<T>... | flag variables to load from. |
|
inlinenoexcept |
Changes specified flags.
| T... | flag types. |
| value | sets flags to this value. |
|
inlinenoexcept |
Get the number of flags.
|
inlinenoexcept |
Returns the value of the specified flag.
| T | flag type. |
|
noexcept |
Converts flags to integral number.
Least significant bit corresponds to the first parameter of the class template.
| T | target integral type. |
| auto typed_flags< Args >::to_string | ( | CharT | zero = CharT('0'), |
| CharT | one = CharT('1') |
||
| ) | const |
Converts flags to standard string.
Rightmost character corresponds to the first parameter of the class template.
| zero | character representing unset flag (optional). |
| one | character representing set flag (optional). |
|
static |
Number of flags i.e. template parameters.
1.8.11