首页
学习
活动
专区
工具
TVP
发布
精选内容/技术社群/优惠产品,尽在小程序
立即前往

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)

二次

代码语言:javascript
复制
#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';
}

二次

产出:

二次

代码语言:javascript
复制
bitset  all     any     none
0000    0       0       1
0101    0       1       0
1111    1       1       0

二次

代码语言:txt
复制
 © cppreference.com

在CreativeCommonsAttribution下授权-ShareAlike未移植许可v3.0。

扫码关注腾讯云开发者

领取腾讯云代金券