Topic: 25.2.12 Partions: return values stated strangely
Author: musiphil@bawi.org (Seungbeom Kim)
Date: Mon, 15 May 2006 04:33:37 GMT Raw View
ISO/IEC 14882:2003 says:
25.2.12 Partitions
template<class BidirectionalIterator, class Predicate>
BidirectionalIterator
partition(BidirectionalIterator first,
BidirectionalIterator last, Predicate pred);
2 Returns: An iterator i such that for any iterator j in the range
[first, i), pred(*j) != false, and for any iterator k in the range
[i, last), pred(*j) == false.
template<class BidirectionalIterator, class Predicate>
BidirectionalIterator
stable_partition(BidirectionalIterator first,
BidirectionalIterator last, Predicate pred);
5 Returns: An iterator i such that for any iterator j in the range
[first, i), pred(*j) != false, and for any iterator k in the range
[i, last), pred(*j) == false. The relative order of the elements
in both groups is preserved.
--------
Paragraphs 2 and 5 both mention "for any iterator k in the range
[i, last)," but none of them ever specifies what conditions k should
satisfy. I suspect that "pred(*j)" immediately following k should
actually have been "pred(*k)".
I searched for this in comp.std.c++ but could not find anything -
is this a defect reported previously?
--
Seungbeom Kim
---
[ 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.comeaucomputing.com/csc/faq.html ]
Author: howard.hinnant@gmail.com (Howard Hinnant)
Date: Mon, 15 May 2006 16:02:32 GMT Raw View
In article <e48vha$6b2$1@news.Stanford.EDU>,
musiphil@bawi.org (Seungbeom Kim) wrote:
> ISO/IEC 14882:2003 says:
>
> 25.2.12 Partitions
>
> template<class BidirectionalIterator, class Predicate>
> BidirectionalIterator
> partition(BidirectionalIterator first,
> BidirectionalIterator last, Predicate pred);
>
> 2 Returns: An iterator i such that for any iterator j in the range
> [first, i), pred(*j) != false, and for any iterator k in the range
> [i, last), pred(*j) == false.
>
> template<class BidirectionalIterator, class Predicate>
> BidirectionalIterator
> stable_partition(BidirectionalIterator first,
> BidirectionalIterator last, Predicate pred);
>
> 5 Returns: An iterator i such that for any iterator j in the range
> [first, i), pred(*j) != false, and for any iterator k in the range
> [i, last), pred(*j) == false. The relative order of the elements
> in both groups is preserved.
>
> --------
>
> Paragraphs 2 and 5 both mention "for any iterator k in the range
> [i, last)," but none of them ever specifies what conditions k should
> satisfy. I suspect that "pred(*j)" immediately following k should
> actually have been "pred(*k)".
>
> I searched for this in comp.std.c++ but could not find anything -
> is this a defect reported previously?
I do believe this is a defect, and I don't believe it has been
previously reported. However the current C++0X working draft (N2009)
has already corrected this error (presumably as editorial).
-Howard
---
[ 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.comeaucomputing.com/csc/faq.html ]