다음을 통해 공유


bitset::operator<<=

Shifts the bits in a bitset to the left a specified number of positions and returns the result to the targeted bitset.

bitset<N>& operator<<=(
      size_t _Pos
);

Parameters

  • _Pos
    The number of positions to the left the bits in the bitset are to be shifted.

Return Value

The targeted bitset modified so that the bits have been shifted to the left the required number of positions.

Remarks

If no element exists to shift into the position, the function clears the bit to a value of 0.

Example

// bitset_op_LSE.cpp
// compile with: /EHsc
#include <bitset>
#include <iostream>

int main( )
{
   using namespace std;
   bitset<5> b1 ( 7 );
   cout << "The target bitset b1 is: ( "<< b1 << " )." << endl;
   b1 <<= 2;
   cout << "After shifting the bits 2 positions to the left,\n"
        << " the target bitset b1 becomes: ( "<< b1 << " )." 
        << endl;
}

The target bitset b1 is: ( 00111 ).
After shifting the bits 2 positions to the left,
 the target bitset b1 becomes: ( 11100 ).

Requirements

Header: <bitset>

Namespace: std

See Also

Concepts

bitset Class

bitset Members