std::bitset::operator[]

(1) bool operator[]( std::size_t pos ) const; (until C++11) constexpr bool operator[]( std::size_t pos ) const; (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 - p

std::bitset::operators

bitset<N> operator<<( std::size_t pos ) const; (1) bitset<N>& operator<<=( std::size_t pos ); (2) bitset<N> operator>>( std::size_t pos ) const; (3) bitset<N>& operator>>=( std::size_t pos ); (4) Performs binary shift left and binary shift right. Zeroes are shifted in. 1-2) Performs binary shift left. The (2) version is destructive, i.e. performs the shift to the current object. 3-4) Performs binary shift right.

std::bitset::operators

bitset<N>& operator&=( const bitset<N>& other ); (1) bitset<N>& operator|=( const bitset<N>& other ); (2) bitset<N>& operator^=( const bitset<N>& other ); (3) bitset<N> operator~() const; (4) Performs binary AND, OR, XOR and NOT. 1) Sets the bits to the result of binary AND on corresponding pairs of bits of *this and other. 2) Sets the bits to the result of binary OR on corresponding pairs of bits

std::bitset::flip

bitset<N>& flip(); (1) bitset<N>& flip( size_t pos ); (2) Flips bits, i.e. changes true values to false and false values to true. Equivalent to a logical NOT operation on part or all of the bitset. 1) Flips all bits (equivalent to operator~) 2) Flips the bit at the position pos. Parameters pos - the position of the bit to flip Return value *this. Exceptions 1) (none) (until C++11) noexcept specification: noexcept (since C++11) 2) thro

std::bitset::count

size_t count() const; Returns the number of bits that are set to true. Parameters (none). Return value number of bits that are set to true. Example #include <iostream> #include <bitset> int main() { std::bitset<8> b("00010010"); std::cout << "initial value: " << b << '\n'; // find the first unset bit size_t idx = 0; while (idx < b.size() && b.test(idx)) ++idx; // continue setting bits until half the

std::bitset::bitset

(1) bitset(); (until C++11) constexpr bitset(); (since C++11) (2) bitset( unsigned long val ); (until C++11) constexpr bitset( unsigned long long val ); (since C++11) (3) template< class CharT, class Traits, class Alloc > explicit bitset( const std::basic_string<CharT,Traits,Alloc>& str, typename std::basic_string<CharT,Traits,Alloc>::size_type pos = 0, typename std::basic_string<CharT,Traits,Alloc>::size_t

std::bitset::all

bool all() const; (1) (since C++11) bool any() const; (2) bool none() const; (3) Checks if all, any or none of the bits are set to true. 1) Checks if all bits are set to true 2) Checks if any bits are set to true 3) Checks if none of the bits are set to true Parameters (none). Return value 1) true if all bits are set to true, otherwise false 2) true if any of the bits are set to true, otherwise false 3) true if none of the bits are set to true, otherwise fal

std::bitset

Defined in header <bitset> template< std::size_t N > class bitset; The class template bitset represents a fixed-size sequence of N bits. Bitsets can be manipulated by standard logic operators and converted to and from strings and integers. bitset meets the requirements of CopyConstructible and CopyAssignable. Template parameters N - the number of bits to allocate storage for Member types reference proxy class representing a reference to a bit (class)

std::binomial_distribution::reset

void reset(); (since C++11) Resets the internal state of the distribution object. After a call to this function, the next call to operator() on the distribution object will not be dependent on previous calls to operator(). Parameters (none). Return value (none). Complexity Constant.

std::binomial_distribution::param

param_type param() const; (1) (since C++11) void param( const param_type& params ); (2) (since C++11) Manages the associated distribution parameter set. 1) Returns the associated parameter set. 2) Sets the associated parameter set to params. Parameters params - new contents of the associated parameter set Return value 1) The associated parameter set. 2) (none). Complexity Constant. Example #include <iostream> #include <random> int main() {