Section: 23.2.7 [associative.reqmts] Status: CD1 Submitter: Hans Aberg Opened: 2001-12-17 Last modified: 2016-01-28
Priority: Not Prioritized
View other active issues in [associative.reqmts].
View all other issues in [associative.reqmts].
View all issues with CD1 status.
Discussion:
Discussions in the thread "Associative container lower/upper bound requirements" on comp.std.c++ suggests that there is a defect in the C++ standard, Table 69 of section 23.1.2, "Associative containers", [lib.associative.reqmts]. It currently says:
a.find(k): returns an iterator pointing to an element with the key equivalent to k, or a.end() if such an element is not found.
a.lower_bound(k): returns an iterator pointing to the first element with key not less than k.
a.upper_bound(k): returns an iterator pointing to the first element with key greater than k.
We have "or a.end() if such an element is not found" for
find
, but not for upper_bound
or
lower_bound
. As the text stands, one would be forced to
insert a new element into the container and return an iterator to that
in case the sought iterator does not exist, which does not seem to be
the intention (and not possible with the "const" versions).
Proposed resolution:
Change Table 69 of section 23.2.7 [associative.reqmts] indicated entries to:
a.lower_bound(k): returns an iterator pointing to the first element with key not less than k, or a.end() if such an element is not found.
a.upper_bound(k): returns an iterator pointing to the first element with key greater than k, or a.end() if such an element is not found.
[Curaçao: LWG reviewed PR.]