Boost logo

Boost Users :

Subject: Re: [Boost-users] [Multi-Index] crash on invariant_() violation
From: Neil Hunt (boost_at_[hidden])
Date: 2009-04-02 23:20:53


>
> ... it doesn't matter if the change is made inside the modify function
> as long as modify is called.
>
> (So, this statement from above does not appear strictly true:
> "Key modification has to be done via modify() so as to give the container a
> chance to reindex elements.")
>
> Because (in my case) the change is made elsewhere, I am calling modify with
>
> a functor that does nothing.
>

I guess more generally, why is this paradigm implictly disallowed?

index_itor->value++;
index.update_indices( index_itor );

While I can see the benefit of tying the modification to the multi-index
object
via modify, there is no explicit reason that I can see why the above is
invalid
(as per my perfectly working code that uses this paradigm).

And "forcing" the user to use a functor to modify can introduce
annoying code overhead.

Don't get me wrong, I think that using modify with a functor is very clear
and
helps prevent invalid indices. But, at the same time, it can be a pain to
write
a functor. (Here's to C++0x lambda's).

But in my case, where the code that modifies the object is unaware of
multi-indices on that object, it is not feasible to use modify() to make
the change.

Neil



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