Re: STL Map Iteration Question
Quote:
Originally Posted by
TSYS
Yes, Philip's code does what I intended, without the equality that bothers you, Paul.
It's not a matter of bothering me, it's really for your benefit to write comparisons this way (without the test for equality). As mentioned, testing for equality as early as you did is the foundation of badly written comparison operators that ultimately break the strict weak ordering rule, maybe not now, but later if the ordering becomes more complex.
I suggest you take Martin O's code, compile it, run it, and see if it works. If it does work, then it's your job to make it not work by adding something to it and repost the changed example. Or if not that, figure out what the code he posted does and your's doesn't do.
Regards,
Paul McKenzie
Re: STL Map Iteration Question
Well, Martin's code certainly works, so now I have to find out what's on the periphery screwing things up.
Thanks to everybody for your help.
Re: STL Map Iteration Question
In Visual Studio 2005, the iterator's operator++ seems to be checking whether the iterator does not belong to a map at all and/or whether it has reached the last element in the map - in which case the "map/set iterator not incrementable" error is issued.
So it is not saying that this type of iterator cannot be incremented, but the specific instance cannot be incremented.