http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57619
Bug ID: 57619
Summary: std::unordered_map and std::unordered_multimap::insert
invoking std::pair move constructor
Product: gcc
Version: unknown
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: libstdc++
Assignee: unassigned at gcc dot gnu.org
Reporter: gdjss2728 at gmail dot com
The following code is invoking the std::pair move constructor:
int main ()
{
std::unordered_mapstd::string, std::string mymap;
std::unordered_multimapstd::string, std::string mymultimap;
std::pairstd::string, std::string mypair{std::string(key),
std::string(value)};
mymultimap.insert(mypair); // std::pair move constructor invoked here
mymap.insert(mypair); // strings already moved out!
}
This seems related to http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53657.
As far as I can tell, overload resolution is choosing `insert(_Pair __x)`
over `insert(const value_type __x)`. Since this is an lvalue, the latter
should be chosen. This happens for std::unordered_map::insert and
std::unordered_multimap::insert.