A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://cplusplus.com/reference/bitset/bitset/none/ below:

public member function

<bitset>

std::bitset::none
bool none() const noexcept;

Test if no bit is set

Returns whether none of the bits is set (i.e., whether all bits in the bitset have a value of zero).

This is the opposite of bitset::any.



Parameters none

Return valuetrue if none of the bits in the bitset is set (to one), and false otherwise.

Example
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
// 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;
}

Possible output:
Please, enter a binary number: 11010111
0000000011010111 has 6 bits set.


Data races The bitset is accessed.

Exception safetyNo-throw guarantee: never throws exceptions.

See also
bitset::count
Count bits set (public member function)
bitset::any
Test if any bit is set (public member function)
bitset::test
Return bit value (public member function)

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4