bitset::to_string

文字列形式への bitset のオブジェクトを変換します。

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

戻り値

ビットが外されれば bitset に設定されている各ビットが 1 の対応する文字を含む、0 かの文字。basic_string クラスの文字列オブジェクト。

使用例

// 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;
}
  

必要条件

ヘッダー: <bitset>

名前空間: std

参照

関連項目

bitset Class