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 类