Why do const
STL containers only return const_iterator
s?
For example both std::vector
and std::list
have the method begin
overloaded
as:
iterator begin();
const_iterator begin() const;
const_iterator cbegin() const;
I thought I could still modify values of a const vector but not the vector itself. According to the standard library there is no difference between:
const std::vector<int>
and
const std::vector<const int>