std::bitset::any
| bool all() const; | (1) | (since C++11) | 
|---|---|---|
| bool any() const; | (2) |  | 
| bool none() const; | (3) |  | 
检查是否所有、任何或任何位都设置为true...
1%29检查是否将所有位设置为true
2%29检查是否将任何位设置为true
3%29检查是否没有将位设置为true
参数
%280%29
返回值
1%29true如果所有位都设置为true,否则false
2%29true如果任何位被设置为true,否则false
3%29true如果没有任何位设置为true,否则false
例外
| (none) | (until C++11) | 
|---|---|
| noexcept specification: noexcept | (since C++11) | 
例
二次
#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二次
 © cppreference.com在CreativeCommonsAttribution下授权-ShareAlike未移植许可v3.0。
本文档系腾讯云开发者社区成员共同维护,如有问题请联系 cloudcommunity@tencent.com

