bitset::to_string |
public member function |
template <class charT, class traits, class Allocator>
basic_string<charT,traits,Allocator> to_string() const; |
|
Convert to string
Constructs a basic_string object that represents the bitset as a succession of zeros and ones.
Notice that this function template uses the template parameters to define the return type. Therefore, they are not implicitly deduced by the compiler.
Parameters
none
Return value
String representing the bitset.
Example
// bitset::to_string
#include <iostream>
#include <string>
#include <bitset>
using namespace std;
int main ()
{
string mystring;
bitset<4> mybits; // mybits: 0000
mybits.set(); // mybits: 1111
mystring=mybits.to_string<char,char_traits<char>,allocator<char> >();
cout << "mystring: " << mystring << endl;
return 0;
}
|
Output:
See also