This page is a snapshot from the LWG issues list, see the Library Active Issues List for more information and the meaning of C++11 status.
Section: 22.9.2.3 [bitset.members] Status: C++11 Submitter: Daniel Krügler Opened: 2008-09-26 Last modified: 2016-01-28
Priority: Not Prioritized
View all other issues in [bitset.members].
View all issues with C++11 status.
Discussion:
The current standard 14882::2003(E) as well as the current draft N2723 have in common a contradiction of the operational semantics of member function test 22.9.2.3 [bitset.members] p.56-58 and the immutable member operator[] overload 22.9.2.3 [bitset.members] p.64-66 (all references are defined in terms of N2723):
bool test(size_t pos) const;
Requires: pos is valid
Throws: out_of_range if pos does not correspond to a valid bit position.
Returns: true if the bit at position pos in *this has the value one.
constexpr bool operator[](size_t pos) const;
Requires: pos shall be valid.
Throws: nothing.
Returns: test(pos).
Three interpretations:
The problem became worse, because issue 720 recently voted into WP argued that member test logically must be a constexpr function, because it was used to define the semantics of another constexpr function (the operator[] overload).
Three alternatives are proposed, corresponding to the three bullets (A), (B), and (C), the author suggests to follow proposal (C).
Proposed alternatives:
Remove the constexpr specifier in front of operator[] overload and undo that of member test (assuming 720 is accepted) in both the class declaration 22.9.2 [template.bitset]/1 and in the member description before 22.9.2.3 [bitset.members]/56 and before /64 to read:
constexprbool test(size_t pos) const; ..constexprbool operator[](size_t pos) const;
Change the throws clause of p. 65 to read:
Throws:
nothingout_of_range if pos does not correspond to a valid bit position.
Replace the throws clause p. 57 to read:
Throws:
out_of_range if pos does not correspond to a valid bit positionnothing.
Undo the addition of the constexpr specifier to the test member function in both class declaration 22.9.2 [template.bitset]/1 and in the member description before 22.9.2.3 [bitset.members]/56, assuming that 720 was applied.
constexprbool test(size_t pos) const;
Change the returns clause p. 66 to read:
Returns:
test(pos)true if the bit at position pos in *this has the value one, otherwise false.
[ Post Summit: ]
Lawrence: proposed resolutions A, B, C are mutually exclusive.
Recommend Review with option C.
[ Batavia (2009-05): ]
We agree with the proposed resolution. Move to Tentatively Ready.
Proposed resolution:
Undo the addition of the constexpr specifier to the test member function in both class declaration 22.9.2 [template.bitset] p.1 and in the member description before 22.9.2.3 [bitset.members] p.56, assuming that 720 was applied.
constexprbool test(size_t pos) const;
Change the returns clause p. 66 to read:
Returns:
test(pos)true if the bit at position pos in *this has the value one, otherwise false.