<xstd/bits/bit_set/bit_flag_mapping.hpp>¶
bit_flag_mapping¶
template<class Key, size_t N = see below>
requires see below
struct bit_flag_mapping {
using block_type = see below;
static constexpr size_t size = N;
static constexpr auto is_key(const Key& key) noexcept -> bool;
static constexpr auto to_index(const Key& key) noexcept -> size_t;
static constexpr auto from_index(size_t index) noexcept -> Key;
static constexpr auto to_block(const Key& mask) noexcept -> block_type;
static constexpr auto from_block(const block_type& block) noexcept -> Key;
};
A bitmask type keyed on its own one-bit values.
Keyis an enumeration, an integer type other thanbooland the character types, or astd::bitset<M>withM > 0.block_typeis the unsigned word a mask is read and written as: an enumeration's or an integer's unsigned counterpart, or for a bitset the least block holdingM, or past the widest block an array of them.Ndefaults to every bit of that word but a sign bit, and for a bitset toM. An enumeration with no fixed underlying type has no default, its values stopping at the bit-field its enumerators need. Mandates:Nis no more than that default width.is_key(k)holds wherekhas exactly one bit set, belowN; zero and a value of several bits are no key.to_index(k)is the position ofk's one bit. Preconditions:khas exactly one bit set.from_index(i)is the value with bitialone. Preconditions:i < N.to_blockandfrom_blockread any value ofKey, one-bit or not, as its block and back, which makes the mapping modelbit_mask_mapping<bit_flag_mapping<Key, N>, Key>.