Standard C++ Library Class Reference
count () const;
Returns a count of the number of bits set in *this.
bitset<N>&
flip();
Flips all bits in *this, and returns *this.
bitset<N>&
flip (size_t pos);
Flips the bit at position pos in *this and returns *this. Throws an out_of_range exception if pos does not correspond
to a valid bit position.
bool
none () const;
Returns true if no bit in *this is set. Otherwise returns false.
bitset<N>&
reset();
Resets all bits in *this, and returns *this.
bitset<N>&
reset (size_t pos);
Resets the bit at position pos in *this. Throws an out_of_range exception if pos does not correspond to a valid bit
position.
bitset<N>&
set();
Sets all bits in *this, and returns *this.
bitset<N>&
set (size_t pos, int val = 1);
Stores a new value in the bits at position pos in *this. If val is nonzero, the stored value is one, otherwise it is zero.
Throws an out_of_range exception if pos does not correspond to a valid bit position.
size_t
size () const;
Returns the template parameter N.
bool
test (size_t pos) const;
Returns true if the bit at position pos is set. Throws an out_of_range exception if pos does not correspond to a valid
bit position.
string
to_string() const;
Returns an object of type string, N characters long.
Each position in the new string is initialized with a character ('0' for zero and '1' for one) representing the value stored
in the corresponding bit position of *this. Character position N - 1 corresponds to bit position 0. Subsequent
decreasing character positions correspond to increasing bit positions.
unsigned long
to_ulong() const;
Returns the integral value corresponding to the bits in *this. Throws an overflow_error if these bits cannot be
represented as type unsigned long.