public member function
unsigned long long to_ullong() const;
Convert to unsigned long long
unsigned long long with the integer value that has the same bits set as the bitset.
If the bitset size is too big to be represented in a value of type
unsigned long long, the function throws an exception of type overflow_error.
Integer value with the same bit representation as the bitset object.
#include <iostream> // std::cout
#include <bitset> // std::bitset
int main ()
std::bitset<4> foo; // foo: 0000
foo.set(); // foo: 1111
std::cout << foo << " as an integer is: " << foo.to_ullong() << '\n';
1111 as an integer is: 15
The bitset is accessed.
Strong guarantee: if an exception is thrown, there are no changes in the bitset.
If the bitset size is too big to be represented by the return type, overflow_error is thrown.