boost::dynamic_bitset::dynamic_bitset
Constructors
Synopses
Declared in <boost/dynamic_bitset/dynamic_bitset.hpp>
Constructs a bitset of size zero.
dynamic_bitset() noexcept(/* see-below */);
Copy constructor.
dynamic_bitset(dynamic_bitset const& b);
Move constructor.
dynamic_bitset(dynamic_bitset&& src) noexcept(/* see-below */);
Constructs a bitset of num_bits bits, all zero.
explicit
dynamic_bitset(size_type num_bits);
Constructs a bitset of size zero.
explicit
dynamic_bitset(allocator_type const& alloc) noexcept(/* see-below */);
Constructs a bitset of num_bits zero bits, which uses a copy of alloc to allocate memory.
explicit
dynamic_bitset(
size_type num_bits,
allocator_type const& alloc);
Allocator‐extended copy constructor.
dynamic_bitset(
dynamic_bitset const& b,
allocator_type const& alloc);
Allocator‐extended move constructor.
dynamic_bitset(
dynamic_bitset&& src,
allocator_type const& alloc) noexcept(/* see-below */);
Constructs a bitset from an integer.
dynamic_bitset(
size_type num_bits,
unsigned long long value,
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 the standard library provides std::basic_string_view, i.e. if the Boost.Config macro BOOST_NO_CXX17_HDR_STRING_VIEW is not defined (typically, in 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, or to an array of characters which need not be null‐terminated (and doesn't take a pos).
template<typename CharT>
requires detail::dynamic_bitset_impl::is_character_type< CharT >::value
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());
Similar to the constructor from a basic_string which takes zero and one, but takes a std::basic_string_view (and no pos or n). Like the constructor from a basic_string_view which doesn't take zero and one, it is only available if the Boost.Config macro BOOST_NO_CXX17_HDR_STRING_VIEW is not defined.
template<
typename CharT,
typename Traits,
typename ZeroOne>
requires detail::dynamic_bitset_impl::is_character_type< CharT >::value && std::is_same< ZeroOne, CharT >::value
explicit
dynamic_bitset(
std::basic_string_view<CharT, Traits> sv,
ZeroOne zero,
ZeroOne one = ZeroOne( '1' ),
size_type num_bits = npos,
allocator_type const& alloc = allocator_type());
Constructs a bitset from a string of 0's and 1's.
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());
Similar to the constructor from a basic_string which takes zero and one, but takes a pointer to a C‐style string, or to an array of characters which need not be null‐terminated (and doesn't take a pos).
template<
typename CharT,
typename ZeroOne>
requires detail::dynamic_bitset_impl::is_character_type< CharT >::value && std::is_same< ZeroOne, CharT >::value
explicit
dynamic_bitset(
CharT const* s,
std::size_t n,
ZeroOne zero,
ZeroOne one = ZeroOne( '1' ),
size_type num_bits = npos,
allocator_type const& alloc = allocator_type());
Constructs a bitset from a string of the characters zero and one.
template<
typename CharT,
typename Traits,
typename Alloc,
typename ZeroOne>
requires detail::dynamic_bitset_impl::is_character_type< CharT >::value && std::is_same< ZeroOne, CharT >::value
explicit
dynamic_bitset(
std::basic_string<CharT, Traits, Alloc> const& s,
std::basic_string<CharT, Traits, Alloc>::size_type pos,
std::basic_string<CharT, Traits, Alloc>::size_type n,
ZeroOne zero,
ZeroOne one = ZeroOne( '1' ),
size_type num_bits = npos,
allocator_type const& alloc = allocator_type());
Parameters
Name |
Description |
num_bits |
The size of the constructed bitset. |
alloc |
An allocator, a copy of which will be used to allocate memory when needed. |
b |
The bitset to copy. |
src |
The bitset to move from. |
value |
The value to initialize the bitset from. |
first |
|
last |
|
sv |
The basic_string_view to construct from. |
s |
The string or array to construct from. |
n |
The maximum number of characters to read from |
zero |
The character which stands for a zero bit. |
one |
The character which stands for a one bit. |
pos |
The start position in the string. |
Preconditions
-
BlockInputIteratormust be either an integral type, an unscoped enumeration type or a model of LegacyInputIterator whosevalue_typeis implicitly convertible toBlockand is neitherboolnor a floating‐point type (astatic_assertchecks this): in particular, a range of `bool`s is not a range of blocks. -
Each character of
svused to initialize a bit compares equal, according toTraits::eq, to eitherCharT( '0' )orCharT( '1' ). E.g.:dynamic_bitset<> b( std::string_view( "10xyz", 2 ) ); // OK. -
‐
spoints to the first character of either a null‐terminated string or an array of at leastncharacters. E.g.:const char a[]= { '1', '0' }; dynamic_bitset<> b( a, 2 ); // OK. ‐ Each character ofsused to initialize a bit compares equal, according tostd::char_traits< CharT >::eq, to eitherCharT( '0' )orCharT( '1' ). E.g.:dynamic_bitset<> b( "10xyz", 2 ); // OK. -
Each character of
svused to initialize a bit compares equal, according toTraits::eq, to eitherzeroorone. -
pos <= s.size()and each character ofsused to initialize a bit compares equal, according toTraits::eq, to eitherCharT( '0' )orCharT( '1' ). Unlike the digits of the stream operators, these don't depend on any locale. E.g.:dynamic_bitset<> b( std::string( "10xyz" ), 0, 2 ); // OK. -
‐
spoints to the first character of either a null‐terminated string or an array of at leastncharacters. ‐ Each character ofsused to initialize a bit compares equal, according tostd::char_traits< CharT >::eq, to eitherzeroorone. -
pos <= s.size()and each character ofsused to initialize a bit compares equal, according toTraits::eq, to eitherzeroorone.
Postconditions
-
this‐>size() == 0. -
For all i in the range
[0, b.size())], `( *this )[ i ] == b[ i ]`. -
src.size() == 0andsrc.num_blocks() == 0, i.e.srcis left empty, and can be used like any other empty bitset. -
‐
this‐>size() == num_bits‐ For all i in the range[0, num_bits)], `( *this )[ i ] == false`. -
this‐>size() == 0 -
this‐>size() == num_bitsandthis‐>none(). -
*this == b. -
‐
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