On 2010-03-08 13:01:32 -0500, Andrei Alexandrescu
<[email protected]> said:
softXxx functions that remove data should guarantee that existing
ranges not including the removed elements will continue to operate on
the range without seeing the removed elements. There is no guarantee
that soft removal offers for ranges spanning the removed elements. (I'm
unclear on this last topic.)
That won't work for a vector as ranges that are further then the
removed element need adjustment too.
Just an idea, perhaps remove and other mutator functions for the
container could take a list of range to update at the same time they do
the operation. This way you don't even need a soft function, if remove
can't accept other ranges then it won't take other ranges as an
argument. For instance:
class Container {
void remove(Range toRemove, Range[] needAdjustment);
}
Container x = new Conatiner();
auto a = x[];
auto b = x[4..6];
auto c = x[2..4];
x.remove(c, [a, b]); // remove elements from c, adjust ranges a and b.
OtherContainer y = new OtherContainer();
auto d = y[];
auto e = y[2..4];
y.remove(e, [d]); // error, container is unable to adjust other ranges.
--
Michel Fortin
[email protected]
http://michelf.com/