boost::dynamic_bitset::dynamic_bitset
Constructors
Synopses
Declared in <boost/dynamic_bitset/dynamic_bitset.hpp>
Constructs a bitset of size zero.
Copy constructor.
dynamic_bitset(dynamic_bitset const& b);
Move constructor.
Constructs a bitset of size zero.
explicit
dynamic_bitset(allocator_type const& alloc);
Constructs a bitset from an integer.
explicit
dynamic_bitset(
size_type num_bits,
unsigned long value = 0,
allocator_type const& alloc = allocator_type());
Constructs a bitset from a range of blocks or from an integer.
template<typename BlockInputIterator>
dynamic_bitset(
BlockInputIterator first,
BlockInputIterator last,
allocator_type const& alloc = allocator_type());
Similar to the constructor from a pointer to a C‐style string, but takes a std::basic_string_view. This constructor is only available if DynamicBitset is compiled as C++17 or later.
template<
typename CharT,
typename Traits>
explicit
dynamic_bitset(
std::basic_string_view<CharT, Traits> sv,
size_type num_bits = npos,
allocator_type const& alloc = allocator_type());
Similar to the constructor from a basic_string, but takes a pointer to a C‐style string (and doesn't take a pos).
template<typename CharT>
explicit
dynamic_bitset(
CharT const* s,
std::size_t n = std::size_t( ‐1 ),
size_type num_bits = npos,
allocator_type const& alloc = allocator_type());
Constructor
template<
typename CharT,
typename Traits,
typename Alloc>
explicit
dynamic_bitset(
std::basic_string<CharT, Traits, Alloc> const& s,
std::basic_string<CharT, Traits, Alloc>::size_type pos = 0,
std::basic_string<CharT, Traits, Alloc>::size_type n = ( std::basic_string< CharT, Traits, Alloc >::npos ),
size_type num_bits = npos,
allocator_type const& alloc = allocator_type());
Parameters
| Name | Description |
|---|---|
alloc |
An allocator, a copy of which will be used to allocate memory when needed. |
num_bits |
The size of the constructed bitset. |
value |
The value to initialize the bitset from. |
first |
|
last |
|
sv |
The basic_string_view to construct from. |
s |
The string to construct from. |
n |
The maximum number of characters in the string to consider. |
pos |
The start position in the string. |
Preconditions
-
BlockInputIteratormust be either an integral type or a model of LegacyInputIterator whosevalue_typeis the same type asBlock. -
The characters in
svthat are use to initialize the bits compare equal to eitherstd::use_facet< std::ctype< CharT > >( std::locale() ).widen( '0' )orstd::use_facet< std::ctype< CharT > >( std::locale() ).widen( '1' ). E.g.:dynamic_bitset<> b( std::string_view( "10xyz", 2 ) ); // OK. -
The characters in
sthat are used to initialize the bits compare equal to eitherstd::use_facet< std::ctype< CharT > >( std::locale() ).widen( '0' )orstd::use_facet< std::ctype< CharT > >( std::locale() ).widen( '1' ). E.g.:dynamic_bitset<> b( "10xyz", 2 ); // OK.
Postconditions
-
this‐>size() == 0. -
For all i in the range
[0, b.size()),( *this )[ i ] == b[ i ]. -
this‐>size() == 0 -
‐
this‐>size() == num_bits‐ For all i in the range[0, M),( *this )[ i ] == ( value >> i ) & 1. ‐ For all i in the range[M, num_bits),( *this )[ i ] == false.
Created with MrDocs