Title
Bitset minor problems
Status
tc1
Section
[template.bitset]
Submitter
Matt Austern

Created on 1998-01-22.00:00:00 last changed 172 months ago

Messages

Date: 2010-10-21.18:28:33

Rationale:

The LWG believes Item 3 is not a defect. "Formatted input" implies the desired semantics. See [istream.formatted].

Date: 2010-10-21.18:28:33

Proposed resolution:

ITEMS 1 AND 2:

In the bitset synopsis ([template.bitset]), replace the member function

    reference operator[](size_t pos);

with the two member functions

    bool operator[](size_t pos) const;
    reference operator[](size_t pos);

Add the following text at the end of [bitset.members], immediately after paragraph 45:

bool operator[](size_t pos) const;
Requires: pos is valid
Throws: nothing
Returns: test(pos)

bitset<N>::reference operator[](size_t pos);
Requires: pos is valid
Throws: nothing
Returns: An object of type bitset<N>::reference such that (*this)[pos] == this->test(pos), and such that (*this)[pos] = val is equivalent to this->set(pos, val);

Date: 1998-01-22.00:00:00

(1) bitset<>::operator[] is mentioned in the class synopsis (23.3.5), but it is not documented in 23.3.5.2.

(2) The class synopsis only gives a single signature for bitset<>::operator[], reference operator[](size_t pos). This doesn't make much sense. It ought to be overloaded on const. reference operator[](size_t pos); bool operator[](size_t pos) const.

(3) Bitset's stream input function (23.3.5.3) ought to skip all whitespace before trying to extract 0s and 1s. The standard doesn't explicitly say that, though. This should go in the Effects clause.

History
Date User Action Args
2010-10-21 18:28:33adminsetmessages: + msg28
2010-10-21 18:28:33adminsetmessages: + msg27
1998-01-22 00:00:00admincreate