C++ Bitset 库 - operator~ 函数
描述
C++ 函数 std::bitset::operator~ 对 bitset 执行按位非运算。
声明
以下是 std::bitset::operator~ 函数形式 std::bitset 头的声明。
C++98
bitset operator~() const;
C++11
bitset operator~() const noexcept;
参数
None
返回值
返回 this 指针。
异常
返回所有位反转的临时位集。
示例
以下示例显示了 std::bitset::operator~ 函数的用法。
#include <iostream>
#include <bitset>
using namespace std;
int main(void) {
bitset<4> b("0000");
cout << ~b << endl;
return 0;
}
让我们编译并运行上面的程序,这将产生以下结果 −
1111

