https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92300
Jonathan Wakely <redi at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|UNCONFIRMED |NEW Last reconfirmed| |2019-10-31 Ever confirmed|0 |1 Severity|normal |enhancement --- Comment #1 from Jonathan Wakely <redi at gcc dot gnu.org> --- make_pair(1, 2) creates a std::pair<int, int> which is not the same type as the value_type. That means there's a conversion from pair<int, int> to pair<const int, int>, which gets done by allocating a node, constructing the value_type into the node, then checking if the key exists. That's the expected behaviour when inserting something that is not the same type as the value_type, so I don't think this is a bug. We could special-case pair<key_type, mapped_type> to avoid that step, because we can use the non-const key directly. Converting it to a const key isn't needed to check if it exists. In fact we could special-case pair<cv key_type, anything>. Confirming as an enhancement request.