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: 23.9.2 [template.bitset] Status: TC1 Submitter: Matt Austern Opened: 1998-01-22 Last modified: 2017-02-03

Priority: Not Prioritized

View all other issues in [template.bitset].

View all issues with TC1 status.


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

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


In the bitset synopsis (23.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 [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);


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