
Joaquín Mª López Muñoz wrote:
Jeff Flinn ha escrito:
JOAQUIN LOPEZ MU?Z wrote:
There is a problem, though: consider the following:
// buggy call ro modify_range modify_range(m,m.begin(),m.end(),adder(2));
What's the problem with this? Well, after *increasing* the value of an element, this is repositioned further to the end of the container, and consequentely modify_range will visit it again and engage in a neverending loop (modulo overflows.)
Would modifying a non_key(or non_derived_key dependency) ever cause repositioning?
I'm not sure if you mean this, but modifying a part of an object from which no
key extractor depends results in no repositioning. For instance
struct element{ int x,y,z };
typedef multi_index_container< element, indexed_by< ordered_unique
, ordered_non_unique , multi_index_t;
modifying element::z in the example above does not cause repositioning ever. Is this what you were referring to?
Yes, that's what I was referring to. So in the above case, there's no need for the 'stable' version.
// calling modify_unstable_range is now OK modify_unstable_range(m,m.begin(),m.end(),adder(2));
Doesn't this actually provide modify_key_range functionality?
No, to provide such functionality just replace the occurences of .modify(...) with .modify_key(...);
So wouldn't the only use of modify_unstable_range be for modifying keys and indirect members? So only a single modify_unstable_range calling .modify_key would suffice? Just thinking out loud here, until I have access to the docs. Thanks for your library and your help. :) Jeff