container stuff

Michel Fortin michel.fortin at michelf.com
Wed May 26 11:31:39 PDT 2010


On 2010-05-26 11:13:38 -0400, Andrei Alexandrescu 
<SeeWebsiteForEmail at erdani.org> said:

> On 05/26/2010 09:37 AM, Michel Fortin wrote:
> 
>> 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.

While it's true that a container could implement a different approach 
for stable and unstable operations, I was more concerned with the need 
to guaranty that only stable operations are performed when passing the 
container to other functions, hence the need for a "soft" (now 
"stable") container wrapper.


-- 
Michel Fortin
michel.fortin at michelf.com
http://michelf.com/



More information about the Digitalmars-d mailing list