This is the mail archive of the firstname.lastname@example.org mailing list for the libstdc++ project. See the libstdc++ home page for more information.
Nathan Myers wrote: > > Chip Salzenberg - a.k.a. - <email@example.com> > >According to Ryszard Kabatek: > >Could someone please fill me in on why that's necessary? I thought > >that plain old pointers were adequate iterators in these cases. > It's not necessary for conformance, but it _is_ necessary for > type-safety. Otherwise any old char* works as an iterator, > no matter where it came from. This is evil. Was I right in assuming that the use of pointers as iterators was also conforming in only the trivial case (i.e. reverse_iterators and the like could not be pointers)? In reference to generic algorithms such as: template<class InputIterator, class T> find(InputIterator first, InputIterator last, const T& value); where you might want to pass in either a standard iterator, or perhaps a reverse iterator, it would be prefereable for the expanded template code to include proper classes instead of simple pointer. I believe this is the type safety refered to in the above. I am curious - would an std::iterator<> expansion of the above template work for any iterators implementing the interface, and save from further specialization of the template? So that normal and reverse iterators would both use the same code with virtual function calls? Not sure how the template mechanism deals with derived classes. Cheers, tim