bitset::to_ulong

bitset を初期化するために含まれるビット使用すると、指定のシーケンスを生成する整数への bitset のオブジェクトを変換します。

unsigned long to_ulong( ) const;

戻り値

指定した場合 bitset の初期化 bitset のビットを生成する整数。

解説

メンバー関数を適用すると、bitset に含まれるビットの順にあると 1、0 桁のシーケンスを持つ整数を返します。

このメンバー関数は、シーケンスのビットはビットが、型の値 unsigned long表すことができないビット値がの場合 overflow_error をスローします*。*

使用例

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

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;

   unsigned long int i;
   i = b1.to_ulong( );
   cout << "The integer returned from the bitset b1,"
        << "\n by the member function to_long( ), that"
        << "\n generated the bits as a base two number is: "
        << i << "." << endl;
}
  

必要条件

ヘッダー: <bitset>

名前空間: std

参照

関連項目

bitset Class