boost::dynamic_bitset::dynamic_bitset
Constructs a bitset from an integer.
Synopsis
Declared in <boost/dynamic_bitset/dynamic_bitset.hpp>
explicit
dynamic_bitset(
size_type num_bits,
unsigned long value = 0,
allocator_type const& alloc = allocator_type());
Description
The first M bits (where M = min( num_bits, std::numeric_limits< unsigned long >::digits )) are initialized to the corresponding bits in value and all other bits, if any, to zero. A copy of the alloc object will be used in subsequent bitset operations such as resize() to allocate memory. Note that, e.g., the following
dynamic_bitset b<>( 16, 7 );
will match the constructor from an iterator range (not this one), but the underlying implementation will still "do the right thing" and construct a bitset of 16 bits, from the value 7.
Throws
An allocation error if memory is exhausted (std::bad_alloc if allocator_type is a std::allocator).
Parameters
| Name | Description |
|---|---|
num_bits |
The size of the constructed bitset. |
value |
The value to initialize the bitset from. |
alloc |
The allocator to use. |
Postconditions
-
‐
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