[#bsl-bitset]
= xref:bsl.adoc[bsl]::bitset
:relfileprefix: ../
:mrdocs:

This class template provides an STL&hyphen;compliant `bitset`&period; For the requirements of a `bitset` class, consult the second revision of the ISO&sol;IEC 14882 Programming Language c&plus;&plus; (2011)&period;

== Synopsis

Declared in `&lt;bslstl&lowbar;bitset&period;h&gt;`

[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
template&lt;std::size&lowbar;t N&gt;
class bitset;
----

== Description

In addition to the methods defined in the standard, this class also provides an extra constructor that takes a `bsl&colon;&colon;basic&lowbar;string`&period; This extra constructor provides the capability to construct a `bitset` from a `bsl&colon;&colon;basic&lowbar;string`, in addition to a `std&colon;&colon;basic&lowbar;string`&period;

== Types

[cols="1,4"]
|===
| Name| Description
| xref:bsl/bitset/reference.adoc[`reference`] 
| This class represents a reference to a modifiable bit inside a `bsl&colon;&colon;bitset`&period;
|===


== 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&period; Note that `all()` and `none()` are both true for bitsets of size 0&period;
| 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&period;
| xref:bsl/bitset/count.adoc[`count`] 
| Return the number of bits in this bitset that have the value of 1&period;
| 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&period; Note that `all()` and `none()` are both true for bitsets of size 0&period;
| xref:bsl/bitset/operator_and_eq.adoc[`operator&amp;&equals;`] 
| Clear each bit of this bitset for each corresponding bit that is 0 in the specified `rhs`, and leaves all other bits unchanged&period; Return a reference to this modifiable bitset&period; Note that this is equivalent to a bitwise OR&period;
| xref:bsl/bitset/operator_lshift_eq.adoc[`operator&lt;&lt;&equals;`] 
| Shift the bits of this bitset left (towards the most significant bit) by the specified `pos` and return a reference to this modifiable bitset&period; For all bits with position I where `I &lt;&equals; pos`, the new value is 0&period; The behavior is undefined unless `pos &lt;&equals; N`&period;
| xref:bsl/bitset/operator_rshift.adoc[`operator&gt;&gt;`] 
| Return a bitset constructed from shifting this bitset right by the specified `pos`&period;
| xref:bsl/bitset/operator_rshift_eq.adoc[`operator&gt;&gt;&equals;`] 
| Shift the bits of this bitset right (towards the least significant bit) by the specified `pos` and return a reference to this modifiable bitset&period; For all bits with position I where `I &gt; N &hyphen; pos`, the new value is 0&period; The behavior is undefined unless `pos &lt;&equals; N`&period;
| xref:bsl/bitset/operator_subs-03.adoc[`operator&lsqb;&rsqb;`] 
| Subscript operators
| xref:bsl/bitset/operator_xor_eq.adoc[`operator&circ;&equals;`] 
| Toggle each bit of this bitset for each corresponding bit that is 1 in the specified `rhs`, and leaves all other bits unchanged&period; Return a reference to this modifiable bitset&period; Note that this is equivalent to a bitwise XOR&period;
| xref:bsl/bitset/operator_or_eq.adoc[`operator&verbar;&equals;`] 
| Set each bit of this bitset for each corresponding bit that is 1 in the specified `rhs`, and leaves all other bits unchanged&period; Return a reference to this modifiable bitset&period; Note that this is equivalent to a bitwise AND&period;
| xref:bsl/bitset/operator_bitnot.adoc[`operator&#126;`] 
| Toggle all bits of this bitset and return a reference to this modifiable bitset&period;
| 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&period;
| xref:bsl/bitset/test.adoc[`test`] 
| Return `true` if the bit at the specified `pos` has the value of 1 and `false` otherwise&period;
| xref:bsl/bitset/to_string.adoc[`to&lowbar;string`] 
| Return a `basic&lowbar;string` representation of this bitset, where the zero&hyphen;bits are represented by the specified `zero` character and the one&hyphen;bits are represented by the specified `one` character&period; The most&hyphen;significant bit is placed at the beginning of the string, and the least&hyphen;significant bit is placed at the end of the string&period;
| xref:bsl/bitset/to_ulong.adoc[`to&lowbar;ulong`] 
| Return an `unsigned` `long` value that has the same bit value as the bitset&period; Note that the behavior is undefined if the bitset cannot be represented as an `unsigned` `long`&period;
| xref:bsl/bitset/operator_lshift.adoc[`operator&lt;&lt;`] 
| Return a bitset constructed from shifting this bitset left by the specified `pos`&period;
| xref:bsl/bitset/operator_eq.adoc[`operator&equals;&equals;`] 
| Return `true` if the specified `rhs` has the same value as this bitset and `false` otherwise&period; Two bitsets have the same value when the sequence and value of bits they hold are the same&period;
| xref:bsl/bitset/operator_not_eq.adoc[`operator!&equals;`] 
| Return `true` if the specified `rhs` do not have the same value as this bitset and `false` otherwise&period; Two bitset do not have the same value when either the sequence or the value of bits they hold are not the same&period;
|===


== Friends

[cols="1,4"]
|===
| Name| Description
| `xref:bsl/reference.adoc[bsl::reference]`
| Proxy providing a mutable reference to a single bit in a `bitset`&period;
|===

== Non-Member Functions

[cols="1,4"]
|===
| Name| Description
| xref:bsl/operator_bitand.adoc[`operator&amp;`]
| Return a `bitset` that results from a bitwise AND of the specified `lhs` and `rhs`&period;
| xref:bsl/operator_xor.adoc[`operator&circ;`]
| Return a `bitset` that results from a bitwise XOR of the specified `lhs` and `rhs`&period;
| xref:bsl/operator_bitor.adoc[`operator&verbar;`]
| Return a `bitset` that results from a bitwise OR of the specified `lhs` and `rhs`&period;
|===


[.small]#Created with https://www.mrdocs.com[MrDocs]#
