std::bitset::all, std::bitset::any, std::bitset::none
来自cppreference.com
![]() |
该页由英文版wiki使用Google Translate机器翻译而来。
该翻译可能存在错误或用词不当。鼠标停留在文本上可以看到原版本。你可以帮助我们修正错误或改进翻译。参见说明请点击这里. |
bool all() const; |
(C++11 起) | |
bool any() const; |
||
bool none() const; |
||
如果所有的检查,或无位被设置为true.
1) 原文:
Checks if all, any or none of the bits are set to true.
检查是否所有位都设置为true
2) 检查是否有任何的位被设置为true
3) 检查,如果没有位被设置为true
原文:
Checks if none of the bits are set to true
[编辑] 参数
(无)
[编辑] 返回值
1)true如果所有位都设置为true,否则false
2) 原文:
true if all bits are set to true, otherwise false
true如果任何的位被设置为true,否则false
3) 原文:
true if any of the bits are set to true, otherwise false
true如果没有位被设置为true,否则false
原文:
true if none of the bits are set to true, otherwise false
[编辑] 示例
#include <iostream> #include <bitset> int main() { std::bitset<4> b1("0000"); std::bitset<4> b2("0101"); std::bitset<4> b3("1111"); std::cout << "bitset\t" << "all\t" << "any\t" << "none\n"; std::cout << b1 << '\t' << b1.all() << '\t' << b1.any() << '\t' << b1.none() << '\n'; std::cout << b2 << '\t' << b2.all() << '\t' << b2.any() << '\t' << b2.none() << '\n'; std::cout << b3 << '\t' << b3.all() << '\t' << b3.any() << '\t' << b3.none() << '\n'; }
输出:
bitset all any none 0000 0 0 1 0101 0 1 0 1111 1 1 0