Re: Checked iterators not standard C++? Porting code from VS6 to VS2008
Moschops <moschops@notvalid.com> wrote:
I'm porting some old C++ code from VS6 to 2008. There is a section
that reads as follows:
ArcList::iterator itr = arcList.end(); itr--;
where the itr is a list iterator. There is some very similar code
where the iterator is a set iterator.
Am I correct in thinking that the new "checked iterators" means that
this will now fail?
Only if the list is empty.
If so, what is the recommended method of setting
an iterator to the last element of a container?
In an empty list, which element is the last one?
Also, am I right in thinking that this code is still legal under
standard C++
Only if the list is non-empty.
and that this "checked iterators" is a Visual Studio
extension?
Checked iterators shouldn't change the meaning of a valid program. If
they do, it's a bug. If you believe you've found such a bug, post a
repro case here.
It's possible - indeed, desirable - that some invalid programs that
appeared to work would fail when compiled with checked iterators. That's
the whole point.
--
With best wishes,
Igor Tandetnik
With sufficient thrust, pigs fly just fine. However, this is not
necessarily a good idea. It is hard to be sure where they are going to
land, and it could be dangerous sitting under them as they fly
overhead. -- RFC 1925