[#bsl-bitset] = xref:bsl.adoc[bsl]::bitset :relfileprefix: ../ :mrdocs: 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). == Synopsis Declared in `<bslstl_bitset.h>` [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- template<std::size_t N> class bitset; ---- == Description 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`. == Types [cols="1,4"] |=== | Name| Description | xref:bsl/bitset/reference.adoc[`reference`] | This class represents a reference to a modifiable bit inside a `bsl::bitset`. |=== == Member Functions [cols="1,4"] |=== | Name| Description | xref:bsl/bitset/2constructor-07.adoc[`bitset`] [.small]#[constructor]# | Constructors | xref:bsl/bitset/all.adoc[`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. | xref:bsl/bitset/any.adoc[`any`] | Return `true` if one or more of the bits in this bitset has the value of 1 and `false` otherwise. | xref:bsl/bitset/count.adoc[`count`] | Return the number of bits in this bitset that have the value of 1. | xref:bsl/bitset/flip-0b.adoc[`flip`] | `flip` overloads | xref:bsl/bitset/none.adoc[`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. | xref:bsl/bitset/operator_and_eq.adoc[`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. | xref:bsl/bitset/operator_lshift_eq.adoc[`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`. | xref:bsl/bitset/operator_rshift.adoc[`operator>>`] | Return a bitset constructed from shifting this bitset right by the specified `pos`. | xref:bsl/bitset/operator_rshift_eq.adoc[`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`. | xref:bsl/bitset/operator_subs-03.adoc[`operator[]`] | Subscript operators | xref:bsl/bitset/operator_xor_eq.adoc[`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. | xref:bsl/bitset/operator_or_eq.adoc[`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. | xref:bsl/bitset/operator_bitnot.adoc[`operator~`] | Toggle all bits of this bitset and return a reference to this modifiable bitset. | xref:bsl/bitset/reset-038.adoc[`reset`] | `reset` overloads | xref:bsl/bitset/set-0c.adoc[`set`] | `set` overloads | xref:bsl/bitset/size.adoc[`size`] | Return the number of bits this bitset holds. | xref:bsl/bitset/test.adoc[`test`] | Return `true` if the bit at the specified `pos` has the value of 1 and `false` otherwise. | xref:bsl/bitset/to_string.adoc[`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. | xref:bsl/bitset/to_ulong.adoc[`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`. | xref:bsl/bitset/operator_lshift.adoc[`operator<<`] | Return a bitset constructed from shifting this bitset left by the specified `pos`. | xref:bsl/bitset/operator_eq.adoc[`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. | xref:bsl/bitset/operator_not_eq.adoc[`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. |=== == Friends [cols="1,4"] |=== | Name| Description | `xref:bsl/reference.adoc[bsl::reference]` | Proxy providing a mutable reference to a single bit in a `bitset`. |=== == Non-Member Functions [cols="1,4"] |=== | Name| Description | xref:bsl/operator_bitand.adoc[`operator&`] | Return a `bitset` that results from a bitwise AND of the specified `lhs` and `rhs`. | xref:bsl/operator_xor.adoc[`operatorˆ`] | Return a `bitset` that results from a bitwise XOR of the specified `lhs` and `rhs`. | xref:bsl/operator_bitor.adoc[`operator|`] | Return a `bitset` that results from a bitwise OR of the specified `lhs` and `rhs`. |=== [.small]#Created with https://www.mrdocs.com[MrDocs]#