Topic: CD2 bug regarding lower/upper_bound?
Author: jpsa@apollo.uk.gdscorp.com (John Aldridge)
Date: 1997/04/04 Raw View
I think the descriptions of the STL functions lower_bound and
upper_bound in sections 25.3.3.1 and 25.3.3.2 of CD2 are wrong.
They both include the wording:
"Returns: The furthermost iterator i in the range [first, last)
such that..."
This wording precludes the functions from returning the value
"last" itself because (section 24 para 7) the range [i, j) does
not include the value j.
This, however, is the iterator which should be returned to
indicate that all values in the searched range are less than (for
lower_bound) or less than or equal to (for upper_bound) the
sought value.
Assuming I've not misread something, and this is a real bug in
the draft, is there somewhere I should send it now that the
public review period is over?
--
Cheers,
John Aldridge
jpsa@uk.gdscorp.com
---
[ 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 ]
[ FAQ: http://reality.sgi.com/employees/austern_mti/std-c++/faq.html ]
[ Policy: http://reality.sgi.com/employees/austern_mti/std-c++/policy.html ]
[ Comments? mailto:std-c++-request@ncar.ucar.edu ]
Author: Roman Lechtchinsky <wolfro@cs.tu-berlin.de>
Date: 1997/04/05 Raw View
John Aldridge wrote:
>
> I think the descriptions of the STL functions lower_bound and
> upper_bound in sections 25.3.3.1 and 25.3.3.2 of CD2 are wrong.
>
> They both include the wording:
>
> "Returns: The furthermost iterator i in the range [first, last)
> such that..."
>
> This wording precludes the functions from returning the value
> "last" itself because (section 24 para 7) the range [i, j) does
> not include the value j.
I don't think this is correct. This section says that the element
pointed to by j is not in the range. The iterator j itself is a valid
iterator, though. This is similar to arrays: if a is declared as int
a[5] then a+5 is a valid pointer even though *(a+5) is not part of the
array. Thus, "iterator i in the range [first,last)" really means that i
is one of {first,...,last} even though only {*first,...,*(last-1)} are
valid elements.
Bye
Roman
---
[ 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 ]
[ FAQ: http://reality.sgi.com/employees/austern_mti/std-c++/faq.html ]
[ Policy: http://reality.sgi.com/employees/austern_mti/std-c++/policy.html ]
[ Comments? mailto:std-c++-request@ncar.ucar.edu ]
Author: Matt Austern <austern@isolde.mti.sgi.com>
Date: 1997/04/05 Raw View
jpsa@apollo.uk.gdscorp.com (John Aldridge) writes:
> They both include the wording:
>
> "Returns: The furthermost iterator i in the range [first, last)
> such that..."
>
> This wording precludes the functions from returning the value
> "last" itself because (section 24 para 7) the range [i, j) does
> not include the value j.
>
> This, however, is the iterator which should be returned to
> indicate that all values in the searched range are less than (for
> lower_bound) or less than or equal to (for upper_bound) the
> sought value.
>
> Assuming I've not misread something, and this is a real bug in
> the draft, is there somewhere I should send it now that the
> public review period is over?
No need, fortunately. This is a bug, yes, but the standardization
committee already knows about it. It is on the US issues list, and it
will be fixed.
---
[ 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 ]
[ FAQ: http://reality.sgi.com/employees/austern_mti/std-c++/faq.html ]
[ Policy: http://reality.sgi.com/employees/austern_mti/std-c++/policy.html ]
[ Comments? mailto:std-c++-request@ncar.ucar.edu ]