Freigeben über


bitset::to_string

Konvertiert ein bitset Objekt einer Zeichenfolgendarstellung.

template<class CharType, class Traits, class Alloc>
   basic_string<CharType, Traits, Alloc> to_string ( ) const;

Rückgabewert

Ein Zeichenfolgenobjekt der Klasse basic_string, wobei jedes Bit, das im bitset festgelegt ist, ein entsprechendes Zeichen von 1 aufweist, und ein Zeichen von 0, wenn das Bit nicht festgelegt ist.

Beispiel

// bitset_to_string.cpp
// compile with: /EHsc
#include <bitset>
#include <iostream>
#include <string>

int main( )
{
   using namespace std;

   bitset<5> b1 ( 7 );

   cout << "The ordered set of bits in the bitset<5> b1( 7 )"
        << "\n that was generated by the number 7 is: ( "
        << b1 << " )" << endl;

   string s1;
   s1 =  b1.template to_string<char, 
   char_traits<char>, allocator<char> >( );
   cout << "The string returned from the bitset b1"
        << "\n by the member function to_string( ) is: "
        << s1 << "." << endl;
}
  

Anforderungen

Header: <bitset>

Namespace: std

Siehe auch

Referenz

bitset Class