If you’re declaring the function const
then your vector member will also be const
, and begin()
and end()
will consequently return const_iterator
s. So you’re fine.
But in general you can always force a const_iterator
by casting a std::vector<T>
instance to std::vector<T> const&
.