Title
std::equal on empty ranges
Status
nad
Section
[alg.equal]
Submitter
Gennaro Prota

Created on 2017-05-26.00:00:00 last changed 90 months ago

Messages

Date: 2017-07-12.01:30:31

Proposed resolution:

This wording is relative to N4659.

  1. Edit [alg.equal] as indicated:

    [Drafting note: The current wording presented below uses two times the unusual phrase "[…] return […]" instead of "[…] returns […]". The project editor is kindly asked to consider to replace these unusual wording forms by the usual one. — end drafting note]

    template<class InputIterator1, class InputIterator2>
      bool equal(InputIterator1 first1, InputIterator1 last1,
                 InputIterator2 first2);
    […]
    

    -1- Remarks: If last2 was not given in the argument list, it denotes first2 + (last1 - first1) below.

    -2- Returns: If [first1, last1) and [first2, last2) are both empty, returns true. If last1 - first1 != last2 - first2, return false. Otherwise return true if for every iterator i in the range [first1, last1) the following corresponding conditions hold: *i == *(first2 + (i - first1)), pred(*i, *(first2 + (i - first1))) != false. Otherwise, returns false.

    […]

Date: 2017-07-12.01:30:31

[ 2017-07 Toronto Monday issue prioritization ]

Closing as NAD; the existing wording covers empty sequences

Date: 2017-05-26.00:00:00

The description of the std::equal() algorithm in the standard doesn't make clear what the result of it is on empty ranges:

std::equal(first, first, second) ; // what does this return?

It should IMHO return true (two empty ranges are always equal).

History
Date User Action Args
2017-07-12 01:30:31adminsetmessages: + msg9334
2017-07-12 01:30:31adminsetstatus: new -> nad
2017-05-27 09:23:31adminsetmessages: + msg9191
2017-05-26 00:00:00admincreate