Re: strange crash after assertion with std::map::iterator
- From: "Stephen Howe" <stephenPOINThoweATtns-globalPOINTcom>
- Date: Mon, 30 Apr 2007 23:05:53 +0100
At the end of this sequence, 'i' is invalid. Would you expect to be able
to test for it? If so, how would you go about it, if you were writing the
C++ standard? How would you go about it if you were STL implementor?
I never said that ANY invalid iterator has to be usable, only that a
value-initialized iterator should be at least equality/inequality
comparable with any other iterator of the same type. the implementation,
I'd bet, would be trivial, since iterators are pointers or they contain
pointers, and pointers may be set to null.
That opens another can of worms.
1. What additional properties (if any), should the standard have for any
iterator where such pointer is null?
2. If I have 2 such iterators, what if I do
sort(it1, it2);
3. end() for a container is not derefenceable and sometimes plays the role
of an "invalid iterator".
Now what happens if I compare a null iterator with end()? - Are they equal?
Less than (for vector and deque)?
Thanks
Stephen Howe
.
- Follow-Ups:
- Re: strange crash after assertion with std::map::iterator
- From: Mycroft Holmes
- Re: strange crash after assertion with std::map::iterator
- Prev by Date: Re: strange crash after assertion with std::map::iterator
- Next by Date: Re: strange crash after assertion with std::map::iterator
- Previous by thread: Re: strange crash after assertion with std::map::iterator
- Next by thread: Re: strange crash after assertion with std::map::iterator
- Index(es):
Relevant Pages
|
Loading