Boost logo

Boost :

Subject: Re: [boost] [interprocess][multi_index] emplace() is not sufficient for maps
From: Ion Gaztañaga (igaztanaga_at_[hidden])
Date: 2009-09-24 16:26:40

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) );



Boost list run by bdawes at, gregod at, cpdaniel at, john at