https://en.cppreference.com/w/cpp/container/vector/insert
Cppreference shows: iterator insert( const_iterator pos, const T& value ); and four other overloads.
But why the parameter is const_iterator but not iterator?
https://en.cppreference.com/w/cpp/container/vector/insert
Cppreference shows: iterator insert( const_iterator pos, const T& value ); and four other overloads.
But why the parameter is const_iterator but not iterator?
Copyright © 2021 Jogjafile Inc.
Whether or not the iterator is const doesn't matter, since the container is the thing being modified (and
insertis not aconst-qualified member function), not the passed in iterator.And this just makes it easier to use. A non-const
iteratoris convertible to aconst_iterator(but not the other way around) so you can still easily use aniterator.A somewhat relevant paper: https://wg21.link/N2350