Hi Ramesh,
 

De: boost-users-bounces@lists.boost.org [boost-users-bounces@lists.boost.org] En nombre de Ramesh [rramesh1@gmail.com]
Enviado el: martes, 12 de agosto de 2008 7:40
Para: boost-users@lists.boost.org
Asunto: [Boost-users] Multi-index container (Modifying non-unique key in the container)
>
> Hi.
>
> I am using boost multi-index container for storing objects of type class A, in the class key1 &
> Key 3 are unique and key2 is non-unique. I try to insert objects of type A and it works fine.
>  No issues.
>
> At some point after the insertion, I wish to modify the key2 to 20  in the container. Can I do this
> with modify? If yes How do I define the iterator (since I need to do a find based on key1 but
> modify key2 in the container)
 
You have two options:
 
1. Use modify(), which is passed the entire element rather than the key, and
modify key2 at your pleasure.
2. Project the key1-iterator to a key2-iterator using the projection facilities:
 
http://www.boost.org/libs/multi_index/doc/tutorial/basics.html#projection
 
and then use modify_key() with the key2-iterator.
 
BTW, I've noticed that you're wrapping the A objects into a DataMap class
that, oddily enough, replicates the key1, key2 and key3 members. Why aren't
you using A members directly thus disposing of the DataMap wrapper?
 
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo