Hi Folks:
Developing on WinXP Home, VS 2008 Pro.
By C++ standards, is it a problem if an iterator
referencing one list's element is tested against a
different list's end()?
I'm keeping a test list, that contains no
elements, for the sole purpose of initializing new
iterators the value of this test list's end().
This test list will never contain elements.
An iterator with a value of this list's end()
is analogous to a pointer with a value of NULL.
The application might create a list, insert
valid data, and assign the iterator to elements
in this new list. This list might never be created,
so I can't initialize the iterator to it's end().
If the iterator is equal to the test list's end(),
I'm assuming it's not referencing an element in the
application's list.
Is this a bad idea?
I'm dusting off an application I wrote 4 years
ago, and Visual C 6.0 had no apparent problem with
this approach.
Running this after a Visual Studio 2008 build
results in the application blowing up when testing
the iterator, now referencing a valid element in one
list, against the test list's end().
Is there a way to make this test work? Or do
I need to re-design my approach to test for valid
iterators?
Thanks
Larry


|