bitset の各ビットを右にシフトし位置の指定した数、新しい bitset に結果が返されます。
bitset<N> operator>>(
size_t _Pos
) const;
パラメーター
- _Pos
bitset の右側の位置は、シフトするビット数です。
戻り値
ビットを対象 bitset に関連して右に移動された新しい位置に必要な数 bitset。
使用例
// bitset_op_RS.cpp
// compile with: /EHsc
#include <bitset>
#include <iostream>
int main( )
{
using namespace std;
bitset<5> b1 ( 7 );
cout << "The bitset b1 is: ( "<< b1 << " )." << endl;
bitset<5> b2;
b2 = b1 << 2;
cout << "After shifting the bits 2 positions to the left,\n"
<< " the bitset b2 is: ( "<< b2 << " )."
<< endl;
bitset<5> b3 = b2 >> 1;
cout << "After shifting the bits 1 position to the right,\n"
<< " the bitset b3 is: ( " << b3 << " )."
<< endl;
}
必要条件
ヘッダー: <bitset>
名前空間: std