std::bitset::operator<<,<<=,>>,>>=
De cppreference.com
|
|
Esta página se ha traducido por ordenador/computador/computadora de la versión en inglés de la Wiki usando Google Translate.
La traducción puede contener errores y palabras aparatosas/incorrectas. Planea sobre el texto para ver la versión original. Puedes ayudar a corregir los errores y mejorar la traducción. Para instrucciones haz clic aquí. |
bitset<N> operator<<( size_t pos ) const;
|
(1) | |
bitset<N>& operator<<=( size_t pos );
|
(2) | |
bitset<N> operator>>( size_t pos ) const;
|
(3) | |
bitset<N>& operator>>=( size_t pos );
|
(4) | |
Performs binary shift left and binary shift right. Zeroes are shifted in.
1-2) Performs binary shift left. The (2) version is destructive, i.e. performs the shift to the current object.
3-4) Performs binary shift right. The (4) version is destructive, i.e. performs the shift to the current object.
Parámetros
| pos | - | number of positions to shift the bits |
Valor de retorno
1,3) new bitset object containing the shifted bits
2,4) *this
Ejemplo
Ejecuta este código
#include <iostream>
#include <bitset>
int main()
{
std::bitset<8> b("01110010");
std::cout << "initial value: " << b << '\n';
while (b.any()) {
while (!b.test(0)) {
b >>= 1;
}
std::cout << b << '\n';
b >>= 1;
}
}
Salida:
initial value: 01110010
00111001
00000111
00000011
00000001
Ver también
| realiza operación binaria AND, OR, XOR y NOT (función miembro pública) |