New std::map::erase signature c++17

  • A+
Category:Languages

According to this answer, an iterator must be implicitly convertible to const_iterator. Since that's true, as we can see on happening in insert_on_assign, why in c++17 was added a new signature to std::map::erase where in c++11 we have iterator erase( const_iterator pos ); and, now, in c++17 we have iterator erase( iterator pos );? Wasn't the c++11 signature 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.

Comment

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen: