bitset::operator>>

将 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

请参见

参考

bitset 类