From: Terje Slettebø (tslettebo_at_[hidden])
Date: 2002-10-13 09:55:55


>From: "Yitzhak Sapir" <yitzhaks_at_[hidden]>

>On Sun, 13 Oct 2002, [iso-8859-1] Terje Slettebø wrote:

>> >Fwiw, I've used --c.end() and am not sorry for it! :-)
>>
>> If you do that on Intel C++ and STLPort for e.g. c=std::string, you get a
>> compile-time error, as c.end() is not a modifiable lvalue. :) In other
>> words, whether or not that work depends on the platform, and is therefore
>> not portable.

>What about boost::prior(c.end()) ?

I assume you mean the one in boost/utility.

It shouldn't make a difference, as it just copies it, and applies -- to the
copy.

As I understand, the only thing you can safely do with an end() iterator is
to compare it with other iterators. A tree class has been discussed
recently. Consider if you e.g. have begin() and end() defined like this:

iterator begin() { return iterator(root); }
iterator end() { return iterator(NULL); }

No amount of ++ or -- on such an end() iterator will make any kind of sense.
Yet, it works just fine for comparison with other iterators.

Regards,

Terje