C++教程
C++控制语句
C++函数
C++数组
C++指针
C++对象
C++继承
C++多态
C++抽象
C++常用
C++ STL教程
C++迭代器
C++程序

C++ none()

C++ bitset none()函数

C++ bitsetnone()函数用于检查是否未设置任何位。如果未设置任何位,则返回true,否则返回false。

语法

bool none(); 

参数

不带任何参数。

返回值

它返回一个布尔值

示例1

#include <iostream>
#include <bitset>
using namespace std;
int main()
{
bitset<16> foo;
bitset<4> b(string("1010")); 
if (foo.none())
cout<< foo << " has no bits set.\n";
else
cout<< foo << " has " <<foo.count() << " bits set.\n";
if (b.none())
cout<< b << " has no bits set.\n";
else
cout<< b << " has " <<b.count() << " bits set.\n";
return 0;
} 
输出:
0000000000000000 has no bits set.
1010 has 2 bits set. 
昵称: 邮箱:
Copyright © 2022 立地货 All Rights Reserved.
备案号:京ICP备14037608号-4