|
Boost Users : |
From: Joaquín Mª López Muñoz (joaquin_at_[hidden])
Date: 2007-02-21 13:37:42
Boris ha escrito:
> On Wed, 21 Feb 2007 19:10:03 +0200, Joaquín Mª López Muñoz
> <joaquin_at_[hidden]> wrote:
[...]
> >
> > m2.modify(it2,null_modifier());
> >
> > which forces reindexation without actually touching *it2. Is this what
> > you're after? Thanks for using Boost.MultiIndex,
>
> Okay, thanks! I thought there might be something else like m2.refresh().
> It would be nice if the multi_index_container provided such a method as
> you could change objects hold by the container directly (not through
> multi_index_container methods) and then make the container recreate the
> indexes.
First of all, one important note of warning: externally modifying elements
is an outright violation of Boost.MultiIndex invariant contract, so strictly
speaking it results in undefined behavior --even if you resync right after
the
modification as I've shown in my previous post. Given that premise,
a refresh() facility cannot even be formulated as it'd operate on a
basically
broken container!
That said, you can force the container to fully recreate its indices after
massive modification with the following non-documented, non-supported
trick:
// modify elements thru m1
...
// force index recreation on m2
// mic_t2 is the type of m2
mic_t2 tmp(m2.begin(),m2.end());
m2.swap(tmp);
I'm almost regretting having posted this trick :) since all of this is
really
completely unguaranteed behavior --so if you can do things in a safer
fashion please go that way.
> Thanks for your nice library, :)
> Boris
You're welcome.
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