Standard C++ Library Class Reference
template <size_t N>
ostream& operator<< (ostream&, const bitset<N>&);
Constructors
bitset();
Constructs an object of class bitset<N>, initializing all bit values to zero.
bitset(unsigned long val);
Constructs an object of class bitset<N>, initializing the first M bit values to the corresponding bits in val. M is the
smaller of N and the value CHAR_BIT * sizeof(unsigned long). If M < N, remaining bit positions are initialized to
zero. Note: CHAR_BIT is defined in <climits>.
explicit
bitset (const string& str, size_t pos = 0,
size_t n = (size_t)-1);
Determines the effective length rlen of the initializing string as the smaller of n and str.size() - pos. The function
throws an invalid_argument exception if any of the rlen characters in str, beginning at position pos,is other than 0 or
1. Otherwise, the function constructs an object of class bitset<N>, initializing the first M bit positions to values
determined from the corresponding characters in the string str. M is the smaller of N and rlen. This constructor
requires that pos <= str.size(), otherwise it throws an out_of_range exception.
bitset(const bitset<N>& rhs);
Copy constructor. Creates a copy of rhs.
Assignment Operator
bitset<N>& operator= (const bitset<N>& rhs);
Erases all bits in self, then inserts into self a copy of each bit in rhs. Returns a reference to *this.
Operators
bool
operator== (const bitset<N>& rhs) const;
Returns true if the value of each bit in *this equals the value of each corresponding bit in rhs. Otherwise returns false.
bool
operator!= (const bitset<N>& rhs) const;
Returns true if the value of any bit in *this is not equal to the value of the corresponding bit in rhs. Otherwise returns
false.
bitset<N>&
operator&= (const bitset<N>& rhs);
Clears each bit in *this for which the corresponding bit in rhs is clear and leaves all other bits unchanged. Returns
*this.
bitset<N>&
operator|= (const bitset<N>& rhs);
Sets each bit in *this for which the corresponding bit in rhs is set, and leaves all other bits unchanged. Returns *this.
bitset<N>&
operator^= (const bitset<N>& rhs);
Toggles each bit in *this for which the corresponding bit in rhs is set, and leaves all other bits unchanged. Returns
*this.
bitset<N>&
operator<<= (size_t pos);