The const
qualifier does not change anything about the definition of the type. So the iterator
type in const std::vector<T>
is the same as in std::vector<T>
. Just use
std::vector<T>::iterator
or, if T
is a template parameter, making this a dependent name:
typename std::vector<T>::iterator
You probably don't want iterator
though, because there is no function of std::vector<T>
that could return an iterator
on a const
qualified instance. You probably want const_iterator
instead.
Generally you don't need to access the iterator type aliases anyway. You can obtain the correct type from auto
in a variable definition:
const std::vector<T> vec{/* ... */};
auto it = vec.begin();
or with decltype
if you need the type itself:
const std::vector<T> vec{/* ... */};
using iterator = decltype(vec.begin());