This page is a snapshot from the LWG issues list, see the Library Active Issues List for more information and the meaning of NAD status.
std::equal
on empty rangesSection: 26.6.13 [alg.equal] Status: NAD Submitter: Gennaro Prota Opened: 2017-05-26 Last modified: 2020-09-06
Priority: Not Prioritized
View all other issues in [alg.equal].
View all issues with NAD status.
Discussion:
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).
[2017-07 Toronto Monday issue prioritization]
Closing as NAD; the existing wording covers empty sequences
Proposed resolution:
This wording is relative to N4659.
Edit 26.6.13 [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
-2- Returns: Iflast2
was not given in the argument list, it denotesfirst2 + (last1 - first1)
below.[first1, last1)
and[first2, last2)
are both empty, returnstrue
. Iflast1 - first1 != last2 - first2
, returnfalse
. Otherwise returntrue
if for every iteratori
in the range[first1, last1)
the following corresponding conditions hold:*i == *(first2 + (i - first1)), pred(*i, *(first2 + (i - first1))) != false
. Otherwise, returnsfalse
. […]