Boost logo

Boost :

Subject: Re: [boost] [interprocess][multi_index] emplace() is not sufficient for maps
From: Thorsten Ottosen (thorsten.ottosen_at_[hidden])
Date: 2009-09-19 04:18:54

Ion Gaztañaga skrev:
> Thorsten Ottosen escribió:

>> Therefore I would like to see the follwing member:
>> iterator modify_key( const_iterator element, const Key& new_key );
>> This function only needs to rebalance/resort the keys and can
>> completely avoid deallocation/allocation.
> Interesting. What about exception safety? We can't assure strong
> guarantee. It could just erase the element if the change fails? We could
> also use the assignment operator instead of destroy+construct to reuse
> some resources.

For keys where assignment don't throw, we get the strong guarantee. For
the case where assignment could throw, I agree the element should be
erase (the user can then reinsert manually if that happens). So maybe
we should return


to tell the user if the update succeeded?

For cases where the ordering is based merely on a non-throwing part of
the Key type, it could be usable with

   template< class Key2 >
   iterator modify_key( const_iterator element, const Key2& new_key );

This function would place the existing node in its right place, but not
change the key object which the user then has to do, e.g.

   iterator i = modify_key( x, new_object.sub_object );
   i->swap( new_object );

I guess there are some additional overloads for movable types.


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