bitset - STL C++

bitset<N>::all()

Declaration

bool bitset<N>::all() const;

Description

This is the member function all() for the bitset class template. This function returns true if all of the bits are equal to 1. Otherwise, the function returns false.

Header Include

#include <bitset>

Example

#include <bitset>
#include <iostream>

int main( )
{
	using namespace std;

	// Create two bitsets
	bitset<4> qBits1(13);
	bitset<4> qBits2(15);
	cout << "bitset<4> #1 : "<< qBits1 << endl;
	cout << "bitset<4> #2 : "<< qBits2 << endl;

	// Call the all() function to test the bitsets.
	cout << "The bits of bitset<4> #1 " << (qBits1.all() ? "are" : "are not")
		<< " all equal to 1." << endl;
	cout << "The bits of bitset<4> #2 " << (qBits2.all() ? "are" : "are not")
		<< " all equal to 1." << endl;

	// Keep the window open
	cin.get();
	return 0;
}

Output

bitset<N>::all() Output
 

© 2007–2024 XoaX.net LLC. All rights reserved.