(1) | ||
bitset operator<<( std::size_t pos ) const; | (until C++11) | |
bitset operator<<( std::size_t pos ) const noexcept; | (since C++11) (until C++23) | |
constexpr bitset operator<<( std::size_t pos ) const noexcept; | (since C++23) | |
(2) | ||
bitset& operator<<=( std::size_t pos ); | (until C++11) | |
bitset& operator<<=( std::size_t pos ) noexcept; | (since C++11) (until C++23) | |
constexpr bitset& operator<<=( std::size_t pos ) noexcept; | (since C++23) | |
(3) | ||
bitset operator>>( std::size_t pos ) const; | (until C++11) | |
bitset operator>>( std::size_t pos ) const noexcept; | (since C++11) (until C++23) | |
constexpr bitset operator>>( std::size_t pos ) const noexcept; | (since C++23) | |
(4) | ||
bitset& operator>>=( std::size_t pos ); | (until C++11) | |
bitset& operator>>=( std::size_t pos ) noexcept; | (since C++11) (until C++23) | |
constexpr bitset& operator>>=( std::size_t pos ) noexcept; | (since C++23) |
Performs binary shift left (towards higher index positions) and binary shift right (towards lower index positions). Zeroes are shifted in, and bits that would go to an index out of range are dropped (ignored).
pos | - | number of positions to shift the bits |
*this
#include <iostream> #include <bitset> int main() { std::bitset<8> b{0b01110010}; std::cout << b << " (initial value)\n"; for (; b.any(); b >>= 1) { for (; !b.test(0); b >>= 1) { } std::cout << b << '\n'; } std::cout << b << " (final value)\n"; }
Output:
01110010 (initial value) 00111001 00000111 00000011 00000001 00000000 (final value)
(C++20) | computes the result of bitwise left-rotation (function template) |
(C++20) | computes the result of bitwise right-rotation (function template) |
performs binary AND, OR, XOR and NOT (public member function) |
© cppreference.com
Licensed under the Creative Commons Attribution-ShareAlike Unported License v3.0.
https://en.cppreference.com/w/cpp/utility/bitset/operator_ltltgtgt