std::bitset

From Cppreference

Jump to: navigation, search
Defined in header <bitset>

template< size_t N >
class bitset;

Bitsets give the programmer a set of bits as a data structure. Bitsets can be manipulated by various binary operators such as logical AND, OR, and so on.

The size of a C++ bitset is fixed at compile-time, and the size is the template parameter to the bitset.

Contents

[edit] Member functions

(constructor)
constructs the bitset
(public member function)
operator=
assigns the contents
(public member function)
operator==
operator!=
compares the contents
(public member function)
Element access
operator[]
accesses specific bit
(public member function)
test
accesses specific bit
(public member function)
all
any
none
checks if all, any or none bits are set to true
(public member function)
count
returns the number of bits set to true
(public member function)
Capacity
size
returns the size number of bits that the bitset can hold
(public member function)
Modifiers
operator&=
operator|=
operator^=
operator~
performs binary AND, OR, XOR and NOT
(public member function)
operator<<=
operator>>=
operator<<
operator>>
performs binary shift left and shift right
(public member function)
set
sets bits to true or given value
(public member function)
reset
sets bits to false
(public member function)
flip
toggles the values of bits
(public member function)
Conversions
to_string
returns a string representation of the data
(public member function)
to_ulong
returns an unsigned long integer representation of the data
(public member function)
to_ullong (C++11)
returns an unsigned long long integer representation of the data
(public member function)

[edit] Helper classes

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