According to this answer, an iterator
must be implicitly convertible to const_iterator
. Since that is true, as we can see happening in insert_or_assign()
, then why in C++17 was a new signature added to std::map::erase()
?
In C++11, we have iterator erase( const_iterator pos );
In C++17, we now have iterator erase( iterator pos );
Wasn't the C++11 signature good enough to receive iterator
and const_iterator
?
There's a potential ambiguity with erase(const key_type& key)
when you pass an iterator
. Consider the case where the key_type
is something like std::any
.