Skip to content

Latest commit

 

History

History
45 lines (32 loc) · 837 Bytes

File metadata and controls

45 lines (32 loc) · 837 Bytes

to_ulong

  • bitset[meta header]
  • std[meta namespace]
  • bitset[meta class]
  • function[meta id-type]
unsigned long to_ulong() const;           // (1) C++03
constexpr unsigned long to_ulong() const; // (1) C++23

概要

unsigned long型に変換する。

戻り値

ビット列をunsigned long型に変換して返す。

例外

unsigned long型に変換した結果としてオーバーフローした場合、overflow_error例外を送出する。

#include <iostream>
#include <bitset>

int main()
{
  std::bitset<4> bs("1011");

  unsigned long result = bs.to_ulong();
  std::cout << result << std::endl;
}

出力

11

参照