Built-in arrays as output ranges
Andrei Alexandrescu
SeeWebsiteForEmail at erdani.org
Mon Feb 8 04:54:54 PST 2010
Steve Teale wrote:
>> enforce() will never be disabled.
>>
>> As an aside, I just realized I haven't implemented put for strings yet,
>> and also that I'd promised a check in this weekend.
>>
>>
>> Andrei
>
> Actually, thinking about this overnight, I'm a bit unhappy about giving
> the impression that a built-in array can serve as an output range. It
> really isn't true unless you never want to see the output again. If you
> do, some data structure is required, either a loose combination of an
> array and an unprotected reference to its original state (arrays a and
> b), or something more explicit like:
>
> struct arrayOutputRange(T)
> {
> T[] array;
> uint pos;
>
> this(uint sx) { ... }
> void put(T val) { ... }
> }
>
> Steve
>
copy(source, target) does make sense for arrays as output ranges. Since
target is passed by value, your copy will see what's been copied.
Andrei
More information about the Digitalmars-d
mailing list