Prevent copy of range in foreach
Yuxuan Shui via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Wed Aug 31 16:38:21 PDT 2016
On Wednesday, 31 August 2016 at 18:28:20 UTC, Ali Çehreli wrote:
> On 08/31/2016 07:03 AM, Yuxuan Shui wrote:
>
> > I want to make a hash table that uses
> > std.experiment.allocator. The bucket is allocated from an
> > allocator, and freed in ~this(). I don't want to copy the
> whole
> > bucket in this(this).
>
> It sounds like you are conflating the concept of a container
> with the concept of a range. The range should be separate from
> the container and should be cheap to copy.
>
> Ali
OK, this would work for cases like containers. But what if I
represent buffered network input as a range (like File.byLine),
and I don't want to copy the buffer all the time? Any suggestion
on how to do that correctly?
More information about the Digitalmars-d-learn
mailing list