std::bitset (3) - Linux Manuals

std::bitset: std::bitset

NAME

std::bitset - std::bitset

Synopsis


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


          proxy class representing a reference to a bit
reference (class)

Member functions


              constructs the bitset
constructor (public member function)
              compares the contents
operator== (public member function)
operator!=

Element access


              accesses specific bit
operator[] (public member function)
              accesses specific bit
test (public member function)


all
any checks if all, any or none of the bits are set to true
none (public member function)


(C++11)


              returns the number of bits set to true
count (public member function)

Capacity


              returns the size number of bits that the bitset can hold
size (public member function)

Modifiers


operator&= performs binary AND, OR, XOR and NOT
operator|= (public member function)
operator^=
operator~


operator<<= performs binary shift left and shift right
operator>>= (public member function)
operator<<
operator>>
              sets bits to true or given value
set (public member function)
              sets bits to false
reset (public member function)
              toggles the values of bits
flip (public member function)

Conversions


              returns a string representation of the data
to_string (public member function)
              returns an unsigned long integer representation of the data
to_ulong (public member function)


to_ullong returns an unsigned long long integer representation of the data
              (public member function)
(C++11)

Non-member functions


operator& performs binary logic operations on bitsets
operator| (function template)
operator^
           performs stream input and output of bitsets
operator<< (function template)
operator>>

Helper classes


std::hash<std::bitset> hash support for std::bitset
                       (class template specialization)
(C++11)

Notes


If the size of the bitset is not known at compile time, std::vector<bool> or boost::dynamic_bitset may be used.