std::vector Iterators

To create an iterator of a vector, you have to use a vector specialization. In the following examples, I create two vector iterators: one for the specialization vector and another for vector. Remember that iterators are strongly-typed, you cannot use an iterator of one vector specialization with another vector specialization:

 #include #include using namespace std;int main(){ vector ::iterator vi_it; vector ::iterator vs_it;}


If you need a generic iterator, use a template:

 inline template vector ::iterator create_iterator( vector  & v){ return vector::iterator();}

Share the Post:
Share on facebook
Share on twitter
Share on linkedin

Overview

Recent Articles: