的问题,这是一个巨大的物体将被复制到地图移动对象到地图
Huge huge1(some,args);
Huge huge2(some,args);
std::map<int,Huge> map1;
std::map<Huge,int> map2;
map1.insert({0,huge1});
map2.insert({huge2,0});
我怎么能保证一招?这工作还是有更多的?
map1.insert({0,std::move(huge1)});
map2.insert({std::move(huge2),0});
我几天前就问过这个:http://stackoverflow.com/questions/14581414/insert-map-entry-by-r-value-moving-of-mapped-type – Chowlett 2013-02-11 16:33:29
不完全一样的东西, @Chowlett。 – Yakk 2013-02-11 16:48:06
@Yakk - ...因为钥匙类型也可以移动,我需要确保它被复制?还是我错过了别的? – Chowlett 2013-02-11 16:59:36