bitset::operator<<

转换。bitset的位左移位置指定数目的并返回相应结果为新的bitset。

bitset<N> operator<<(
   size_t _Pos
) const;

参数

  • _Pos
    位置的数量到左边bitset的位将转换。

返回值

中的位的修改后的bitset传输到左侧位置所需的数目。

备注

成员运算符函数返回 bitset(*this) <<= pos,<<= 转换。bitset的位左移位置指定数目的并返回相应结果到目标的bitset的位置。

示例

// bitset_op_LS.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;
}

Output

The bitset b1 is: ( 00111 ).
After shifting the bits 2 positions to the left,
 the bitset b2 is: ( 11100 ).
After shifting the bits 1 position to the right,
 the bitset b3 is: ( 01110 ).

要求

标头: <bitset>

命名空间: std

请参见

参考

bitset Class