Transient ranges

Andrei Alexandrescu via Digitalmars-d digitalmars-d at puremagic.com
Mon May 30 05:44:14 PDT 2016


On 05/30/2016 08:21 AM, Joseph Rushton Wakeling wrote:
> On Sunday, 29 May 2016 at 17:29:35 UTC, Steven Schveighoffer wrote:
>> This doesn't help at all. I can still make a "transient" range with
>> all three range primitives.
>>
>> There seems to be a misunderstanding about what a transient range is.
>>
>> byLine is a transient range that requires the front element be
>> cacheable (I have to build the line somewhere, and reusing that buffer
>> provides performance). Shoehorning into a popFront-only style "range"
>> does not solve the problem. Not only that, but now I would have to
>> cache BOTH the front element and the next one.
>
> Ack, yea, I think see the issue.  It's
>
>      auto a = transientRange.front;
>      transientRange.popFront() // <=== now a has changed
>
> Even if you go with the only-2-primitives one, you'd have the same problem:
>
>      auto a = transientRange.front;
>      auto b = transientRange.front;   // <=== now a has changed

That's right. The one approach that works here is to acknowledge the 
range has no buffering at all and require the user to provide the buffer 
as an argument. However, that would make for a different primitive that 
does not fit within the range hierarchy. -- Andrei



More information about the Digitalmars-d mailing list