共用方式為


bitset::to_ulong

轉換為的話會產生中的位元組序列初始化 bitset 的整數 bitset 物件。

unsigned long to_ulong( ) const;

傳回值

如果使用則會產生一 bitset 的位元在 bitset 初始化的整數。

備註

套用成員函式會傳回具有 1 和 0 位數相同順序的整數像循序位於 bitset 包含的位元組。

成員函式擲回 overflow_error ,如果以位元組序列的任何位元組不能表示為型別 unsigned long的值的位元值*。*

範例

// 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 類別