This page is a snapshot from the LWG issues list, see the Library Active Issues List for more information and the meaning of TC1 status.

### 11. Bitset minor problems

Section: 20.9.2 [template.bitset] Status: TC1 Submitter: Matt Austern Opened: 1998-01-22 Last modified: 2016-08-09

Priority: Not Prioritized

View all other issues in [template.bitset].

View all issues with TC1 status.

Discussion:

(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.

Proposed resolution:

ITEMS 1 AND 2:
In the bitset synopsis (20.9.2 [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 20.9.2.3 [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);`

Rationale:

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