[RFC] libstdc++/8780

Martin Sebor sebor@roguewave.com
Wed Dec 4 09:14:00 GMT 2002


Joe Buck wrote:
...
> 
> This should be an FAQ, along with suggestions on how users can fix their
> code that implicitly assumes that std::vector<T>::iterator is T*.  Even
> programmers who know better tend to make this mistake when they develop
> code on compilers that use such an implementation.
> 
> The short answer is that, given
>     std::vector<T>::iterator iter_T;
> 
> then
>     &*iter_T
> 
> has type T* and points to the same object.  As the elements of a vector
> must be contiguous, this works portably.

Unfortunately, it will not work for an iterator pointing at the end
of a container.

Regards
Martin



More information about the Libstdc++ mailing list