Created on 1999-08-13.00:00:00 last changed 172 months ago
Rationale:
bool is a better choice. It is believed that binary compatibility is not an issue, because this member function is usually implemented as inline, and because it is already the case that users cannot rely on the type of a pointer to a nonvirtual member of a standard library class.
[ Post-Tokyo: Andy provided the above wording. ]
[ Kona: The LWG agrees with the description. Andy Sawyer will work on better P/R wording. ]
Proposed resolution:
In [template.bitset] Para 1 Replace:
bitset<N>& set(size_t pos, int val = true );
With:
bitset<N>& set(size_t pos, bool val = true );
In [bitset.members] Para 12(.5) Replace:
bitset<N>& set(size_t pos, int val = 1 );
With:
bitset<N>& set(size_t pos, bool val = true );
In section [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.
History | |||
---|---|---|---|
Date | User | Action | Args |
2010-10-21 18:28:33 | admin | set | messages: + msg1797 |
2010-10-21 18:28:33 | admin | set | messages: + msg1796 |
2010-10-21 18:28:33 | admin | set | messages: + msg1795 |
2010-10-21 18:28:33 | admin | set | messages: + msg1794 |
1999-08-13 00:00:00 | admin | create |