I made a collection for which I want to provide an STL-style, random-access iterator. I was searching around for an example implementation of an iterator but I didn\'t find
First of all you can look here for a list of the various operations the individual iterator types need to support.
Next, when you have made your iterator class you need to either specialize std::iterator_traits for it and provide some necessary typedef
s (like iterator_category
or value_type
) or alternatively derive it from std::iterator, which defines the needed typedef
s for you and can therefore be used with the default std::iterator_traits
.
disclaimer: I know some people don't like cplusplus.com
that much, but they provide some really useful information on this.