bsl::bitset

STL-compliant fixed-size sequence of N bits.

Synopsis

Declared in <bslstl_bitset.h>

template<std::size_t N>
class bitset;

Description

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).

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

NameDescription
reference This class represents a reference to a modifiable bit inside a bsl::bitset.

Member Functions

NameDescription
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 bits of this bitset where the corresponding bits of rhs are 0.
operator<<= Shift the bits of this bitset left by the specified pos.
operator>> Return a bitset constructed from shifting this bitset right by the specified pos.
operator>>= Shift the bits of this bitset right by the specified pos.
operator[] Subscript operators
operator^= Toggle bits of this bitset where the corresponding bits of rhs are 1.
operator|= Set bits of this bitset where the corresponding bits of rhs are 1.
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 string representation of this bitset using zero and one.
to_ulong Return an unsigned long with the same bit pattern as this bitset.
operator<< Return a bitset constructed from shifting this bitset left by the specified pos.
operator== Return true if rhs has the same bit values as this bitset.
operator!= Return true if rhs does not have the same bit values as this bitset.

Friends

NameDescription
bsl::referenceProxy providing a mutable reference to a single bit in a bitset.

Non-Member Functions

NameDescription
operator&Return a bitset that results from a bitwise AND of the specified lhs and rhs.
operator^Return a bitset that results from a bitwise XOR of the specified lhs and rhs.
operator|Return a bitset that results from a bitwise OR of the specified lhs and rhs.