Title
find algorithm missing version that takes a binary predicate argument
Status
nad
Section
[alg.find]
Submitter
Pablo Halpern

Created on 2000-03-06.00:00:00 last changed 172 months ago

Messages

Date: 2010-10-21.18:28:33

Rationale:

This is request for a pure extension, so it is not a defect in the current standard.  As the submitter pointed out, "this can be accomplished using a combination of find_if and bind_1st or bind_2nd".

Date: 2010-10-21.18:28:33

Proposed resolution:

In section [alg.find], add a second prototype for find (between the existing prototype and the prototype for find_if), as follows:

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

Change the description of the return from:

Returns: The first iterator i in the range [first, last) for which the following corresponding conditions hold: *i == value, pred(*i) != false. Returns last if no such iterator is found.

 to:

Returns: The first iterator i in the range [first, last) for which the following  corresponding condition holds: *i == value, bin_pred(*i,value) != false, pred(*) != false. Return last if no such iterator is found.

Date: 2010-10-21.18:28:33

[ 2009-07 Frankfurt ]

The same thing can be achieved using find_if (as noted in the issue).

Moved to NAD.

Date: 2010-10-21.18:28:33

[ Summit: ]

Reopened by Alisdair.

Date: 2000-03-06.00:00:00

The find function always searches for a value using operator== to compare the value argument to each element in the input iterator range. This is inconsistent with other find-related functions such as find_end and find_first_of, which allow the caller to specify a binary predicate object to be used for determining equality. The fact that this can be accomplished using a combination of find_if and bind_1st or bind_2nd does not negate the desirability of a consistent, simple, alternative interface to find.

History
Date User Action Args
2010-10-21 18:28:33adminsetmessages: + msg1892
2010-10-21 18:28:33adminsetmessages: + msg1891
2010-10-21 18:28:33adminsetmessages: + msg1890
2010-10-21 18:28:33adminsetmessages: + msg1889
2000-03-06 00:00:00admincreate