std::bitset::bitset
(1) | ||
bitset(); |
(until C++11) | |
constexpr bitset(); |
(since C++11) | |
(2) | ||
bitset( unsigned long val ); |
(until C++11) | |
constexpr bitset( unsigned long long val ); |
(since C++11) | |
(3) | ||
template< class CharT, class Traits, class Alloc > explicit bitset( const std::basic_string<CharT,Traits,Alloc>& str, |
(until C++11) | |
template< class CharT, class Traits, class Alloc > explicit bitset( const std::basic_string<CharT,Traits,Alloc>& str, |
(since C++11) | |
template< class CharT > explicit bitset( const CharT* str, |
(4) | (since C++11) |
Constructs a new bitset from one of several optional data sources:
M
bit positions to the corresponding bit values of val
, where M
is the smaller of the number of bits in an unsigned long long
and the number of bits N
in the bitset being constructed. If M is less than N (the bitset is longer than 32 (until C++11)64 (since C++11) bits, for typical implementations of unsigned long (since C++11)long), the remaining bit positions are initialized to zeroes. str
. An optional starting position pos
and length n
can be provided, as well as characters denoting alternate values for set (one
) and unset (zero
) bits. Traits::eq()
is used to compare the character values. n
, str.size() - pos
).pos > str.size()
, this constructor throws std::out_of_range. If any characters examined in str
are not zero
or one
, it throws std::invalid_argument.CharT*
instead of a std::basic_string. Equivalent to bitset(n == basic_string<CharT>::npos ? basic_string<CharT>(str) : basic_string<CharT>(str, n), 0, n, zero, one)Parameters
val | - | number used to initialize the bitset |
str | - | string used to initialize the bitset |
pos | - | a starting offset into str
|
n | - | number of characters to use from str
|
one | - | alternate character for set bits in str
|
zero | - | alternate character for unset bits in str
|
Exceptions
1) none
2) none
|
(until C++11) |
1)
noexcept specification: noexcept 2) noexcept specification:
noexcept |
(since C++11) |