Topic: Defect Report: second parameter to bitset::set should be bool, not int


Author: "Darin Adler" <darin@bentspoon.com>
Date: 1999/08/14
Raw View
 [Moderator's note: this defect report has been forwarded to the
 C++ committee.  -moderator (fjh).]

In section 23.3.5.2 [lib.bitset.members], paragraph 13 defines the
bitset::set operation to take a second parameter of type int. The function
tests whether this value is non-zero to determine whether to set the bit to
true or false. The type of this second parameter should be bool. For one
thing, the intent is to specify a boolean value. For another, the result
type from test() is bool. In addition, it's possible to slice an integer
that's larger than an int. This can't happen with bool, since conversion to
bool has the semantic of translating 0 to false and any non-zero value to
true.

The type of the second parameter to bitset::set should be changed to bool in
23.3.5.2 [lib.bitset.members], paragraph 13 and in 23.3.5
[lib.template.bitset] in the summary of class bitset.

    -- Darin
---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://reality.sgi.com/austern_mti/std-c++/faq.html              ]