Re: Prevent copy of range in foreach

2016-08-31 Thread Mike Parker via Digitalmars-d-learn
On Wednesday, 31 August 2016 at 23:38:21 UTC, Yuxuan Shui wrote: 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? Then

Re: Prevent copy of range in foreach

2016-08-31 Thread Yuxuan Shui via Digitalmars-d-learn
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

Re: Prevent copy of range in foreach

2016-08-31 Thread Ali Çehreli via Digitalmars-d-learn
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

Re: Prevent copy of range in foreach

2016-08-31 Thread pineapple via Digitalmars-d-learn
On Wednesday, 31 August 2016 at 14:03:20 UTC, 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). Maybe I should use a reference counter or

Re: Prevent copy of range in foreach

2016-08-31 Thread Yuxuan Shui via Digitalmars-d-learn
On Tuesday, 30 August 2016 at 20:30:12 UTC, Ali Çehreli wrote: On 08/30/2016 12:06 PM, Yuxuan Shui wrote: Is there a way to use a range defined with disabled post-blit in foreach? In other words, is there a way to prevent foreach from copying the range? It's not possible. You can't do much

Re: Prevent copy of range in foreach

2016-08-31 Thread mogu via Digitalmars-d-learn
On Tuesday, 30 August 2016 at 19:06:46 UTC, Yuxuan Shui wrote: Is there a way to use a range defined with disabled post-blit in foreach? In other words, is there a way to prevent foreach from copying the range? Should I use move()? 国人?望加群:531010036 谢谢

Re: Prevent copy of range in foreach

2016-08-30 Thread Ali Çehreli via Digitalmars-d-learn
On 08/30/2016 12:06 PM, Yuxuan Shui wrote: Is there a way to use a range defined with disabled post-blit in foreach? In other words, is there a way to prevent foreach from copying the range? It's not possible. You can't do much with such a range anyway. For example, even r.take(10) requires

Prevent copy of range in foreach

2016-08-30 Thread Yuxuan Shui via Digitalmars-d-learn
Is there a way to use a range defined with disabled post-blit in foreach? In other words, is there a way to prevent foreach from copying the range? Should I use move()?