Thanks Joaquín,
Will try modify & the reasons I am wrapping the map class with a another one
is to make sure that the users of the class just get access to APIs and not
to the container as such & and also each key is used by a different classes
to do lookups. Hence two unique keys.
Thanks for your response.
Regards
Ramesh
On Tue, Aug 12, 2008 at 11:31 AM, JOAQUIN M. LOPEZ MUÑOZ
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
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
A, in the class key1 & 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
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users