<xstd/bits/bit_ranges/from_blocks.hpp>¶
xstd::from_blocks_t, xstd::from_blocks¶
struct from_blocks_t { explicit from_blocks_t() = default; };
inline constexpr from_blocks_t from_blocks{};
A tag that says at the call site that an argument's blocks are read as bits, rather than as keys or elements:
bit_fixed_set<32>(from_blocks, 5u) is {0, 2}, the positions the value five has. Its default constructor is
explicit, so {} cannot stand in for it.
Notes¶
- Every owner of ours takes the tag: a fixed width reads any blocks that hold at least its width, and a run-time width
adopts its own block container.
bit_constructible_fromnames the blocks an owner takes as they are. - The deduction guides of
basic_bit_arrayandbasic_bit_fixed_setdeduce the block and the widthbit_blocks_extent_vnames, from an unsigned integer, anarrayof them or a built-in array of them, as [span.deduct] takes an array's bound:basic_bit_array(from_blocks, uint16_t{...})isbasic_bit_array<uint16_t, 16>;basic_bit_fixed_set(from_blocks, array<uint8_t, 3>{...})isbasic_bit_fixed_set<size_t, uint8_t, 24>;- an empty
arraydeduces width zero.
- The deduction guides of
basic_bit_vectorandbasic_bit_setdeduce the storage from the container they adopt:basic_bit_vector(from_blocks, vector<uint8_t>{...})isbasic_bit_vector<vector<uint8_t>>, and over a storage of constant capacity the width is that capacity in bits. - A signed integer, or an
arrayof them, deduces nothing, and a run-time width takes no block of a fixed width:bit_vectoris not constructible fromfrom_blocksand auint64_t. - A type that has bit storage without being it, such as a
bitset<64>or abit_array<64>, is not read through the tag. It converts throughbit_convert.
See also¶
| Entity | Relation |
|---|---|
bit_constructible_from |
the blocks an owner takes through the tag as they are |
bit_blocks_extent_v |
the width the deduction guides read off the blocks |
bit_convert |
the conversion for a type that has bit storage without being it |
from_range_t |
the standard's tag for an argument's elements, whose role this tag takes for its blocks |