Subject: Re: [boost] [iterator] UB when implicitly using default constructed counting_iterator<unsigned>
From: Claas H. KÃ¶hler (claas.koehler_at_[hidden])
Date: 2012-12-05 11:55:16
On 05/12/12 17:31, Peter Sommerlad wrote:
> Just to clarify
> A singular iterator can be safely compared with other iterators. It can not be dereferenced or incremented.
> A default constructed boost::counting_iterator<unsigned> can not safely be compared.
Can you cite a part of the standard which guarantees this? I only found 24.2.1, number 5 (in my
preliminary version of the C++11 standard)
Results of most expressions are undefined for singular values; the only exceptions are destroying an
iterator that holds a singular value, the assignment of a non-singular value to an iterator that
holds a singular value, and, for iterators that satisfy the DefaultConstructible requirements, using
a value-initialized iterator as the source of a copy or move operation. [ Note: This guarantee is not
offered for default initialization, although the distinction only matters for types with trivial
default constructors such as pointers or aggregates holding pointers. â end note ] In these cases the
singular value is overwritten the same way as any other value. Dereferenceable values are always
>From which part do you conclude that comparisons are well-defined?
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk