Title
upper_bound(first, last, ...) cannot return last
Status
cd1
Section
[upper.bound]
Submitter
Seungbeom Kim

Created on 2006-05-03.00:00:00 last changed 164 months ago

Messages

Date: 2010-10-21.18:28:33

Proposed resolution:

Change [lib.upper.bound]:

Returns: The furthermost iterator i in the range [first, last)] such that for any iterator j in the range [first, i) the following corresponding conditions hold: !(value < *j) or comp(value, *j) == false.

Date: 2006-05-03.00:00:00

ISO/IEC 14882:2003 says:

25.3.3.2 upper_bound

Returns: The furthermost iterator i in the range [first, last) such that for any iterator j in the range [first, i) the following corresponding conditions hold: !(value < *j) or comp(value, *j) == false.

From the description above, upper_bound cannot return last, since it's not in the interval [first, last). This seems to be a typo, because if value is greater than or equal to any other values in the range, or if the range is empty, returning last seems to be the intended behaviour. The corresponding interval for lower_bound is also [first, last].

History
Date User Action Args
2010-10-21 18:28:33adminsetmessages: + msg3104
2006-05-03 00:00:00admincreate