Go back to Richel Bilderbeek's homepage.

Go back to Richel Bilderbeek's C++ page.

 

 

 

(C++) const_iterator

 

Common typedef in containers for an iterator-type that can only read the element it is located at.

 

 

 

#include <vector>

 

const std::vector<int> v(10,0);

const std::vector<int>::const_iterator i = v.begin();

 

 

Closer inspection (of vector.h for example) yields the following typedefs:

 

 

typedef _TYPENAME __value_alloc_type::const_pointer const_iterator;

 

typedef const T* const_pointer;

 

 

This concludes that the following two data types are equivalent:

 

 

std::vector<int>::const_iterator DataTypeOne;

const int * DataTypeOne;

 

 

 

Go back to Richel Bilderbeek's C++ page.

Go back to Richel Bilderbeek's homepage.