Skip to content

Latest commit

 

History

History
53 lines (38 loc) · 1.07 KB

op_right_shift.md

File metadata and controls

53 lines (38 loc) · 1.07 KB

operator>>

  • bitset[meta header]
  • std[meta namespace]
  • bitset[meta class]
  • function[meta id-type]
bitset<N> operator>>(size_t pos) const;                    // (1) C++03
bitset<N> operator>>(size_t pos) const noexcept;           // (1) C++11
constexpr bitset<N> operator>>(size_t pos) const noexcept; // (1) C++23

概要

ビットを右シフトしたbitsetオブジェクトを生成する。

戻り値

*thisのビットをposの個数だけ右にシフトさせたbitsetオブジェクトを生成して返す。溢れたビットは0になる。
この関数は、以下のプログラムと同じ動作をする:

return bitset(*this) >>= pos;
  • =[link op_right_shift_assign.md]

例外

投げない。

#include <iostream>
#include <bitset>

int main()
{
  std::bitset<8> bs("11000001");

  std::bitset<8> result = bs >> 4;

  std::cout << result << std::endl;
}

出力

00001100

参照