Go back to Richel Bilderbeek's homepage.

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

 

 

 

 

 

(C++) const_iterator

 

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

 

#include <vector>

int main()
{
  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.

 

Valid XHTML 1.0 Strict