如果位未设置为1。bitset对象,测试。
bool none( ) const;
返回值
true,如果在bitset的位未设置为1; false,如果至少有一个设置为1。
示例
// bitset_none.cpp
// compile with: /EHsc
#include <bitset>
#include <iostream>
int main( )
{
using namespace std;
bitset<5> b1 ( 6 );
bool b, rb;
cout << "Original bitset b1(6) is: ( " << b1 << " )"
<< endl;
b = b1.none ( );
if ( b )
cout << "None of the bits in bitset b1 are set to 1."
<< endl;
else
cout << "At least one of the bits in bitset b1 is set to 1."
<< endl;
bitset<5> rb1;
rb1 = b1.reset ( );
rb = rb1.none ( );
if ( rb )
cout << "None of the bits in bitset b1 are set to 1."
<< endl;
else
cout << "At least one of the bits in bitset b1 is set to 1."
<< endl;
}
要求
标头: <bitset>
命名空间: std