std::bitset::operator<<,<<=,>>,>>=
来自cppreference.com
该页由英文版wiki使用Google Translate机器翻译而来。
该翻译可能存在错误或用词不当。鼠标停留在文本上可以看到原版本。你可以帮助我们修正错误或改进翻译。参见说明请点击这里. |
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.
目录 |
[编辑] 参数
pos | - | number of positions to shift the bits |
[编辑] 返回值
1,3) new bitset object containing the shifted bits
2,4) *this
[编辑] 示例
#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; } }
输出:
initial value: 01110010 00111001 00000111 00000011 00000001
[编辑] 另请参阅
执行二进制AND,OR,XOR和NOT 原文: performs binary AND, OR, XOR and NOT (公共成员函数) |