SeeWebsiteForEmail at erdani.org
Wed May 26 08:13:38 PDT 2010
On 05/26/2010 09:37 AM, Michel Fortin wrote:
> On 2010-05-25 18:27:32 -0400, Andrei Alexandrescu
> <SeeWebsiteForEmail at erdani.org> said:
>> There are a bunch of "soft" primitives. Those are meant to put a stop
>> to the iterator invalidation problems experienced in the STL. The
>> container implementor may alias softXyz to xyz if she knows the
>> operation won't mess the ranges currently iterating the container
>> (which is the case for most node-based containers). I haven't yet
>> discussed subtler cases in which a range starts with a removed element
>> etc., but I plan to.
> Looks good, but I think something is missing. While I agree with the
> idea of having distinguishable "soft" operations, to pass it to other
> functions you should be able to make a "soft" shell around your
> container and pass that shell mapping non-soft functions to soft ones,
> ensuring only soft functions can be called. It could look like this:
> insertAtRandomPlace(myContainer.soft, element);
> Now you know insertAtRandom won't and *can't* invalidate your
> iterators/ranges, and you don't need to write a separate
> "softInsertAtRandom" that only calls soft functions.
Initially I thought containers that naturally support soft (well,
"stable" since 5 minutes ago) operations would simply alias the
non-stable versions and the stable versions to the same call.
But now you got me thinking that a container might want to take
advantage of both to implement slightly different approaches. I haven't
met such a container yet, but that doesn't mean they aren't possible.
More information about the Digitalmars-d