Created on 2001-01-14.00:00:00 last changed 161 months ago
Rationale:
[operators] paragraph 10 already specifies the semantics. That paragraph says that, if declarations of operator!=, operator>, operator<=, and operator>= appear without definitions, they are defined as specified in [operators]. There should be no user confusion, since that paragraph happens to immediately precede the specification of pair.
Proposed resolution:
After p20 [pairs] add:
template <class T1, class T2> bool operator!=(const pair<T1,T2>& x, const pair<T1,T2>& y);Returns: !(x==y)
template <class T1, class T2> bool operator> (const pair<T1,T2>& x, const pair<T1,T2>& y);Returns: y < x
template <class T1, class T2> bool operator>=(const pair<T1,T2>& x, const pair<T1,T2>& y);Returns: !(x < y)
template <class T1, class T2> bool operator<=(const pair<T1,T2>& x, const pair<T1,T2>& y);Returns: !(y < x)
[ 2009-10 Santa Cruz: ]
Move to Ready
[ 2009-10-11 Daniel opens 1233 which deals with the same issue as it pertains to unique_ptr. ]
[ 2009-09-27 Alisdair reopens. ]
The issue is a lack of wording specifying the semantics of std::pair relational operators. The rationale is that this is covered by catch-all wording in the relops component, and that as relops directly precedes pair in the document this is an easy connection to make.
Reading the current working paper I make two observations:
- relops no longer immediately precedes pair in the order of specification. However, even if it did, there is a lot of pair specification itself between the (apparently) unrelated relops and the relational operators for pair. (The catch-all still requires operator== and operator< to be specified explicitly)
- No other library component relies on the catch-all clause. The following all explicitly document all six relational operators, usually in a manner that could have deferred to the relops clause.
tuple unique_ptr duration time_point basic_string queue stack move_iterator reverse_iterator regex submatch thread::idThe container components provide their own (equivalent) definition in [container.requirements.general] Table 90 -- Container requirements and do so do not defer to relops.
Shared_ptr explicitly documents operator!= and does not supply the other 3 missing operators (>,>=,<=) so does not meet the reqirements of the relops clause.
Weak_ptr only supports operator< so would not be covered by relops.
At the very least I would request a note pointing to the relops clause we rely on to provide this definition. If this route is taken, I would recommend reducing many of the above listed clauses to a similar note rather than providing redundant specification.
My preference would be to supply the 4 missing specifications consistent with the rest of the library.
The synopsis of the header <utility> in [utility] lists the complete set of equality and relational operators for pair but the section describing the template and the operators only describes operator==() and operator<(), and it fails to mention any requirements on the template arguments. The remaining operators are not mentioned at all.
History | |||
---|---|---|---|
Date | User | Action | Args |
2011-08-23 20:07:26 | admin | set | status: wp -> c++11 |
2010-10-21 18:28:33 | admin | set | messages: + msg2149 |
2010-10-21 18:28:33 | admin | set | messages: + msg2148 |
2010-10-21 18:28:33 | admin | set | messages: + msg2147 |
2010-10-21 18:28:33 | admin | set | messages: + msg2146 |
2010-10-21 18:28:33 | admin | set | messages: + msg2145 |
2001-01-14 00:00:00 | admin | create |