forward ranges must offer a save() function

Rainer Deyke rainerd at eldwood.com
Sat May 30 10:38:53 PDT 2009


Andrei Alexandrescu wrote:
> If we want to allow people to create ranges that are classes (as opposed
> to structs) the requirement for a save() function is a must. This is
> because copying class ranges with
> 
> Range copy = original;
> 
> only creates a new alias for original; the two share the same state.

Allowing ranges to have either value or reference semantics is a
disaster, because it turns two very common and very obvious operations
(assignment and argument passing) into implementation-defined behavior.
I prefer value semantics over reference semantics, but using either one
consistently would be infinitely preferable over leaving the choice to
the implementor.


-- 
Rainer Deyke - rainerd at eldwood.com



More information about the Digitalmars-d mailing list