std::
bitset::none
公众成员函数 <bitset>
C++98; |
bool none() const; |
C++11; |
bool none() const noexcept; |
返回是否有bit被设置
返回是否所有位都没有设置(即,是否bitset中的所有位值都为零)。
这与bitset::any相反。
☲ 参数
-
none
☉ 返回值
如果bitset中的所有位都没有被设置,则为True,否则为false。
☣ 示例
// bitset::none
#include <iostream> // std::cin, std::cout
#include <bitset> // std::bitset
int main ()
{
std::bitset<16> foo;
std::cout << "Please, enter a binary number: ";
std::cin >> foo;
if (foo.none())
std::cout << foo << " has no bits set.\n";
else
std::cout << foo << " has " << foo.count() << " bits set.\n";
return 0;
}
|
输出:
Please, enter a binary number: 11010111
0000000011010111 has 6 bits set.
⇄ 数据竞争
访问bitset对象。
☂ 异常安全性
无抛出保证:从不抛出异常。
🍄 另请参阅