This is the mail archive of the libstdc++@gcc.gnu.org mailing list for the libstdc++ project.
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |
Other format: | [Raw text] |
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
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |