If the default constructor is used, the bitset is initialized with zeros, otherwise its initial content depends on the parameters used:
Parameters
- val
- Integral value whose bits are copied to the bitset elements, up to the smaller of the bitset size and the size in bits of an unsigned long.
- str
- String containing a binary value (zeros and ones). These are parsed and used to initizialize the bits. If some character other than zero or one is found, the function throws an invalid_argument exception.
- pos
- First character in the string to be read as the content for the bitset.
- n
- Number of characters to read. A value of string::npos specifies that as many characters as possible are to be read.
Example
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
|
The code does not produce any output, but demonstrates some ways in which a bitset container can be constructed.
See also
| bitset::set | Set bits (public member function) |
| bitset::reset | Reset bits (public member function) |
| bitset::operator[] | Access bit (public member function) |
| bitset::operator | Bitset operators (functions) |
