GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages
std::bitset::to_string(3) C++ Standard Libary std::bitset::to_string(3)

std::bitset::to_string - std::bitset::to_string


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> (until C++23)
> std::basic_string<CharT, Traits, Allocator>


to_string( CharT zero = CharT('0'), CharT one = CharT('1') ) const;
template<


class CharT = char,
class Traits = std::char_traits<CharT>,
class Allocator = std::allocator<CharT> (since C++23)
> std::basic_string<CharT, Traits, Allocator>
constexpr


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.


zero - character to use to represent false
one - character to use to represent true


the converted string


May throw std::bad_alloc from the std::string constructor.

// Run this code


#include <iostream>
#include <bitset>
int main()
{
std::bitset<8> b(42);
std::cout << b.to_string() << '\n'
<< b.to_string('*') << '\n'
<< b.to_string('O', 'X') << '\n';
}


00101010
**1*1*1*
OOXOXOXO


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

2022.07.31 http://cppreference.com

Search for    or go to Top of page |  Section 3 |  Main Index

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with ManDoc.