Freigeben über


bitset::operator<<

Verschiebt die Bits eines Bitset auf eine angegebene Anzahl Positionen verlassen und gibt das Ergebnis in einen neuen Bitset zurück.

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

Parameter

  • _Pos
    Die Anzahl der Positionen nach links, dass die Bits im Bitset verschoben werden sollen.

Rückgabewert

Das geänderte Bitset Bits mit den verschob sich die erforderliche Anzahl der Positionen bei.

Hinweise

Die Memberoperatorfunktion gibt bitset zurück (*this)<<= pos,<<=, die die Bits eines Bitset auf eine angegebene Anzahl Positionen links bewegt und das Ergebnis dem verwendeten Bitset zurückgibt.

Beispiel

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

Ausgabe

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 ).

Anforderungen

Header: <Bitset>

Namespace: std

Siehe auch

Referenz

bitset-Klasse