Title
Associative container lower/upper bound requirements
Status
cd1
Section
[associative.reqmts]
Submitter
Hans Aberg

Created on 2001-12-17.00:00:00 last changed 172 months ago

Messages

Date: 2010-10-21.18:28:33

[ CuraƧao: LWG reviewed PR. ]

Date: 2010-10-21.18:28:33

Proposed resolution:

Change Table 69 of section [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.

Date: 2001-12-17.00:00:00

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).

History
Date User Action Args
2010-10-21 18:28:33adminsetmessages: + msg2331
2010-10-21 18:28:33adminsetmessages: + msg2330
2001-12-17 00:00:00admincreate