C++ Bitset 库 - to_ullong() 函数
描述
C++ 函数 std::bitset::to_ullong() 将 bitset 转换为无符号长整数。
声明
以下是 std::bitset::to_ullong() 函数形式 std::bitset 头的声明。
C++98
unsigned long long to_ullong() const;
参数
None
返回值
将位集返回为无符号长数。
异常
如果抛出异常,bitset 不会发生变化。
示例
以下示例显示了 std::bitset::to_ullong() 函数的用法。
#include <iostream>
#include <bitset>
#include <typeinfo>
using namespace std;
int main(void) {
bitset<4> b("1010");;
auto result = b.to_ullong();
cout << "Decimal representation of " << b << " = " << result << endl;
return 0;
}
让我们编译并运行上面的程序,这将产生以下结果 −
Decimal representation of 1010 = 10

