Hi, Pierangelo Masarati schrieb:
I see no problem with dereferencing end(), and doing operations like end()+<integer>. In that case, end() should return a proper iterator as a temporary and on these the operations +,- are defined (somewhere 24.1.5 in the standard, I believe). But maybe there is a ++ or -- involved?
As far as I recall, end() cannot be dereferenced, but only used to test for out-of-range. In any case, to track problems run-time with
yes, sorry, you're right. The dereferencing is of course not guaranteed to work. But the arithmetic is nevertheless allowed (at least officially). I mixed up that sentence, because in the standard the conditions on the operations ++,--,etc. involving these iterators are often defined using the notion of dereferencing. For the ++ operation there is an exemption to the requirement for iterators to be dereferenceable. Regards, Jens