std::bitset<N>::operator<<,<<=,>>,>>=

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

# Declarations

bitset operator<<( std::size_t pos ) const;

(noexcept since C++11) (constexpr since C++23)

bitset& operator<<=( std::size_t pos );

(noexcept since C++11) (constexpr since C++23)

bitset operator>>( std::size_t pos ) const;

(noexcept since C++11) (constexpr since C++23)

bitset& operator>>=( std::size_t pos );

(noexcept since C++11) (constexpr since C++23)

# Parameters

# Example

#include <bitset>
#include <iostream>
 
int main()
{
    std::bitset<8> b{0b01110010};
    std::cout << b << " (initial value)\n";
 
    for (; b.any(); b >>= 1)
    {
        while (!b.test(0))
            b >>= 1;
        std::cout << b << '\n';
    }
 
    std::cout << b << " (final value)\n";
}

# See also