Boost logo

Boost :

From: David Abrahams (dave_at_[hidden])
Date: 2004-07-19 08:42:41


Stefan Slapeta <stefan_nospam__at_[hidden]> writes:

> David Abrahams wrote:
>
>> If STLPort is complaining about that, it's because what you're doing
>> is illegal. A default constructed standard container iterator is
>> "singular", and no operations on it (including comparison) are legal
>> other than assigning a non-singular iterator value into it. Although
>> a few specialized iterators in std:: work differently
>> (e.g. istream_iterator), in general you have to make the same
>> assumption for any other iterator.
>
> I know that but I don't know if Pavol was aware of it. The
> directory_iterator in the filesystem library also has the same
> behaviour if default constructed

Not AFAICT, it doesn't!

> and [although it's no iterator on a standard container and can't
> cause any assertions in STLPort therefore] the filesystem
> documentation reads: 'Class directory_iterator provides a C++
> standard conforming input iterator ...'.

As well it is. Conforming iterators are not required to be
problematic when default-constructed. See istream_iterator.

>>>Any solution which doesn't break the syntax? I don't have any idea
>>>which could be implemented easily...
>> Post some more detail about what you mean by "the syntax" please.
>
> I meant not changing the library interface but maybe this behaviour of
> default constructed iterators _has_ to be removed. I will try to find
> all these occurences later.

No it does not, but it may cost you an extra bool in your iterator
class.

-- 
Dave Abrahams
Boost Consulting
http://www.boost-consulting.com

Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk