C++ <bitset> - operator>>= Function
The C++ bitset::operator>>= function is used to perform bitwise right SHIFT operation on the current bitset object.
Syntax
bitset& operator>>= (size_t pos);
bitset& operator>>= (size_t pos) noexcept;
Parameters
pos |
Specify number of bit locations to be shifted. |
Return Value
*this
Exception
Never throws exceptions.
Example:
In the example below, the bitset::operator>>= function is used to perform bitwise right SHIFT operation on the current bitset object.
#include <iostream> #include <bitset> using namespace std; int main (){ bitset<4> bset("1001"); cout<<"bset is: "<<bset; //performing bitwise right shift operation on bset bset>>=2; cout<<"\n(bset>>2): "<<bset; return 0; }
The output of the above code will be:
bset is: 1001 (bset>>2): 0010
❮ C++ <bitset> Library