Boost logo

Boost Users :

From: Joaquín Mª López Muñoz (joaquin_at_[hidden])
Date: 2007-02-21 12:10:03


Hello Boris,

Boris ha escrito:

> I have two multi_index_containers with smart pointers which refer to the
> same objects (at least some of the pointers refer to the objects). When I
> access and modify an object via an index of one of the two
> multi_index_containers the indexes of that container are recreated as far
> as I understand.

Correct, if you've used replace(), modify() or modify_key() to do the
modification.

> But how do I make the other multi_index_container
> recreate its indexes? I can't and don't need to modify the object again.
> Is there anything to force a multi_index_container to recreate its indexes?

Let's call m1 the first multi_index_container (the one you're modyfing the
element through) and m2 the second one. If you've got an m2-iterator to
the modified element, let's call it it2, then you can do the following just
after
the modification:

  struct null_modifier
  {
    template<typename T>
    void operator()(const T&)const{}
  };

  ...

  m2.modify(it2,null_modifier());

which forces reindexation without actually touching *it2. Is this what
you're after? Thanks for using Boost.MultiIndex,

Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net