std::bitset<N>::to_string (3) - Linux Manuals
std::bitset<N>::to_string: std::bitset<N>::to_string
NAME
std::bitset<N>::to_string - std::bitset<N>::to_string
Synopsis
template<
class CharT,
class Traits, (until C++11)
class Alloc
> std::basic_string<CharT,Traits,Allocator> to_string() const;
template<
class CharT = char,
class Traits = std::char_traits<CharT>, (since C++11)
class Allocator = std::allocator<CharT>
> std::basic_string<CharT,Traits,Allocator>
to_string(CharT zero = CharT('0'), CharT one = CharT('1')) const;
Converts the contents of the bitset to a string. Uses zero to represent bits with value of false and one to represent bits with value of true.
The resulting string contains N characters with the first character corresponds to the last (N-1th) bit and the last character corresponding to the first bit.
Parameters
zero - character to use to represent false
one - character to use to represent true
Return value
the converted string
Exceptions
May throw std::bad_alloc from the the std::string constructor.
Example
// Run this code
Output:
See also
to_ulong (public member function)
to_ullong returns an unsigned long long integer representation of the data
(C++11)