boost::dynamic_bitset::to_string

Returns a representation of *this as a string of zero and one characters, highest bit first.

Synopsis

Declared in <boost/dynamic_bitset/dynamic_bitset.hpp>

template<
    typename CharT = char,
    typename Traits = std::char_traits<CharT>,
    typename Allocator = std::allocator<CharT>>
std::basic_string<CharT, Traits, Allocator>
to_string(
    CharT zero = CharT( '0' ),
    CharT one = CharT( '1' )) const;

Description

Like std::bitset::to_string(). E.g., dynamic_bitset<>( 4, 13ul ).to_string() is the std::string "1101", and dynamic_bitset<>( 4, 13ul ).to_string< wchar_t >( L'.', L'*' ) is the std::wstring L"**.*". Unlike the stream inserter, this function doesn't depend on any locale.

Throws

An allocation error if memory is exhausted (std::bad_alloc if Allocator is a std::allocator).

Return Value

A string s of size size() such that, for all i in the range [0, size())], s[ i ] is one if ( *this )[ size() ‐ 1 ‐ i ] is set, and zero otherwise.

Parameters

Name

Description

zero

The character which stands for a zero bit.

one

The character which stands for a one bit.

Created with MrDocs