
24 Sep
2009
24 Sep
'09
8:26 p.m.
Howard Hinnant escribió:
This is effectively the same thing as:
typedef ... map; map m; map::node_ptr p = m.remove(m.emplace_hint(m.begin(), my_special_cheap_key_value, mv1, mv2)); p->first = modify( p->second ); m.insert( boost::move(p) );
Removing something just after inserting it seems a bit useless. Even if we insert in the first position we need to do a comparison to make sure the hint is correct.Why not: map::node_ptr p = m.create_node(my_special_cheap_key_value, mv1, mv2); //We would need to unconst-cast... const_cast<Key&>(p->first) = modify( p->second ); m.insert( boost::move(p) ); Best, Ion