Title
std::bitset::all() missing
Status
cd1
Section
[template.bitset]
Submitter
Martin Sebor

Created on 2007-06-22.00:00:00 last changed 172 months ago

Messages

Date: 2010-10-21.18:28:33

Proposed resolution:

Add a declaration of the new member function all() to the defintion of the bitset template in [template.bitset], p1, right above the declaration of any() as shown below:

bool operator!=(const bitset<N>& rhs) const;
bool test(size_t pos) const;
bool all() const;
bool any() const;
bool none() const;

Add a description of the new member function to the end of [bitset.members] with the following text:

bool all() const;

Returns: count() == size().

In addition, change the description of any() and none() for consistency with all() as follows:

bool any() const;

Returns: true if any bit in *this is onecount() != 0.

bool none() const;

Returns: true if no bit in *this is onecount() == 0.

Date: 2007-06-22.00:00:00

The bitset class template provides the member function any() to determine whether an object of the type has any bits set, and the member function none() to determine whether all of an object's bits are clear. However, the template does not provide a corresponding function to discover whether a bitset object has all its bits set. While it is possible, even easy, to obtain this information by comparing the result of count() with the result of size() for equality (i.e., via b.count() == b.size()) the operation is less efficient than a member function designed specifically for that purpose could be. (count() must count all non-zero bits in a bitset a word at a time while all() could stop counting as soon as it encountered the first word with a zero bit).

History
Date User Action Args
2010-10-21 18:28:33adminsetmessages: + msg3457
2007-06-22 00:00:00admincreate