std::bitset<N>::operator[] (3) - Linux Manuals
std::bitset<N>::operator[]: std::bitset<N>::operator[]
NAME
std::bitset<N>::operator[] - std::bitset<N>::operator[]
Synopsis
bool operator[]( std::size_t pos ) const; (until C++11)
constexpr bool operator[]( std::size_t pos ) const; (1) (since C++11)
reference operator[]( std::size_t pos ); (2)
Accesses the bit at position pos. The first version returns the value of the bit, the second version returns an object of type std::bitset::reference that allows modification of the value.
Unlike test(), does not throw exceptions: the behavior is undefined if pos is out of bounds.
Parameters
pos - position of the bit to return
Return value
1) the value of the requested bit
2) an object of type std::bitset::reference, which allows writing to the requested bit.
Exceptions
None
Example
// Run this code
Output:
See also
test (public member function)