This class template provides an STL-compliant bitset. For the requirements of a bitset class, consult the second revision of the ISO/IEC 14882 Programming Language c++ (2011).
Declared in <bslstl_bitset.h>
template<std::size_t N>
class bitset;
In addition to the methods defined in the standard, this class also provides an extra constructor that takes a bsl::basic_string. This extra constructor provides the capability to construct a bitset from a bsl::basic_string, in addition to a std::basic_string.
| Name | Description |
|---|---|
reference | This class represents a reference to a modifiable bit inside a bsl::bitset. |
| Name | Description |
|---|---|
bitset [constructor] | Constructors |
all | Return true if all of the bits in this bitset have the value of 1 and false otherwise. Note that all() and none() are both true for bitsets of size 0. |
any | Return true if one or more of the bits in this bitset has the value of 1 and false otherwise. |
count | Return the number of bits in this bitset that have the value of 1. |
flip | flip overloads |
none | Return true if all the bits in this bitset has the value of 0 and false otherwise. Note that all() and none() are both true for bitsets of size 0. |
operator&= | Clear each bit of this bitset for each corresponding bit that is 0 in the specified rhs, and leaves all other bits unchanged. Return a reference to this modifiable bitset. Note that this is equivalent to a bitwise OR. |
operator<<= | Shift the bits of this bitset left (towards the most significant bit) by the specified pos and return a reference to this modifiable bitset. For all bits with position I where I <= pos, the new value is 0. The behavior is undefined unless pos <= N. |
operator>> | Return a bitset constructed from shifting this bitset right by the specified pos. |
operator>>= | Shift the bits of this bitset right (towards the least significant bit) by the specified pos and return a reference to this modifiable bitset. For all bits with position I where I > N - pos, the new value is 0. The behavior is undefined unless pos <= N. |
operator[] | Subscript operators |
operator^= | Toggle each bit of this bitset for each corresponding bit that is 1 in the specified rhs, and leaves all other bits unchanged. Return a reference to this modifiable bitset. Note that this is equivalent to a bitwise XOR. |
operator|= | Set each bit of this bitset for each corresponding bit that is 1 in the specified rhs, and leaves all other bits unchanged. Return a reference to this modifiable bitset. Note that this is equivalent to a bitwise AND. |
operator~ | Toggle all bits of this bitset and return a reference to this modifiable bitset. |
reset | reset overloads |
set | set overloads |
size | Return the number of bits this bitset holds. |
test | Return true if the bit at the specified pos has the value of 1 and false otherwise. |
to_string | Return a basic_string representation of this bitset, where the zero-bits are represented by the specified zero character and the one-bits are represented by the specified one character. The most-significant bit is placed at the beginning of the string, and the least-significant bit is placed at the end of the string. |
to_ulong | Return an unsigned long value that has the same bit value as the bitset. Note that the behavior is undefined if the bitset cannot be represented as an unsigned long. |
operator<< | Return a bitset constructed from shifting this bitset left by the specified pos. |
operator== | Return true if the specified rhs has the same value as this bitset and false otherwise. Two bitsets have the same value when the sequence and value of bits they hold are the same. |
operator!= | Return true if the specified rhs do not have the same value as this bitset and false otherwise. Two bitset do not have the same value when either the sequence or the value of bits they hold are not the same. |
| Name | Description |
|---|---|
bsl::reference | Proxy providing a mutable reference to a single bit in a bitset. |