Title
Heterogeneous equality and EqualityComparable
Status
dup
Section
[alg.nonmodifying] [alg.modifying.operations]
Submitter
Peter Dimov

Created on 2004-09-20.00:00:00 last changed 171 months ago

Messages

Date: 2010-10-21.18:28:33

Rationale:

Duplicate of (a subset of) issue 283.

Duplicate: 283

Date: 2010-10-21.18:28:33

Proposed resolution:

[lib.alg.find]:

Remove [lib.alg.find]/1.

[lib.alg.count]:

Remove [lib.alg.count]/1.

[lib.alg.search]:

Remove "Type T is EqualityComparable (20.1.1), " from [lib.alg.search]/4.

[lib.alg.replace]:

Remove [lib.alg.replace]/1. Replace [lb.alg.replace]/2 with:

For every iterator i in the range [first, last) for which *i == value or pred(*i) holds perform *i = new_value.

Remove the first sentence of /4. Replace the beginning of /5 with:

For every iterator i in the range [result, result + (last - first)), assign to *i either...

(Note the defect here, current text says assign to i, not *i).

[lib.alg.fill]:

Remove "Type T is Assignable (23.1), " from /1. Replace /2 with:

For every iterator i in the range [first, last) or [first, first + n), perform *i = value.

[lib.alg.remove]:

Remove /1. Remove the first sentence of /6.

Date: 2004-09-20.00:00:00

c++std-lib-14262

[lib.alg.find] requires T to be EqualityComparable:

template <class InputIterator, class T>
   InputIterator find(InputIterator first, InputIterator last,
                      const T& value);

However the condition being tested, as specified in the Effects clause, is actually *i == value, where i is an InputIterator.

The two clauses are in agreement only if the type of *i is T, but this isn't necessarily the case. *i may have a heterogeneous comparison operator that takes a T, or a T may be convertible to the type of *i.

Further discussion (c++std-lib-14264): this problem affects a number of algorithsm in clause 25, not just find. We should try to resolve this problem everywhere it appears.

History
Date User Action Args
2010-10-21 18:28:33adminsetmessages: + msg2802
2010-10-21 18:28:33adminsetmessages: + msg2801
2004-09-20 00:00:00admincreate