Topic: Defect Report: Associative container lower/upper bound requirements


Author: remove.haberg@matematik.su.se (Hans Aberg)
Date: 16 Dec 01 18:39:59 GMT
Raw View
 [Moderator's note: this defect report has been
 forwarded to the C++ committee. -moderator.]

Discussions in the thread "Associative container lower/upper bound
requirements" 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.

It appears that the text of a.lower_bound(k) and a.upper_bound(k) should
be completed 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.

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

  Hans Aberg      * Anti-spam: remove "remove." from email address.
                  * Email: Hans Aberg <remove.haberg@member.ams.org>
                  * Home Page: <http://www.matematik.su.se/~haberg/>
                  * AMS member listing: <http://www.ams.org/cml/>
---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.research.att.com/~austern/csc/faq.html                ]