C++ bitset all()函数用于测试是否设置了bitset中的所有位。它返回一个布尔值,即true或false。
bool all() const no except;
它返回布尔值true或false。
#include <iostream> #include <bitset> using namespace std; int main() { bitset<4> b; bitset<4> mask("1111"); if (!b.all()) cout<< "All bits are not set." <<endl; b |= mask; if (b.all()) cout<< "All bit are set." <<endl; return 0; }
输出:
All bits are not set. All bit are set.
祝学习愉快!(内容编辑有误?请选中要编辑内容 -> 右键 -> 修改 -> 提交!)