Is this range behaviour correct?

Jesse Phillips Jessekphillips+D at gmail.com
Thu Mar 14 16:58:33 PDT 2013


On Thursday, 14 March 2013 at 21:40:34 UTC, Ali Çehreli wrote:
> I had toyed with the idea of making a ForwardRange from an 
> InputRange by caching the elements. Without any guarantees, :) 
> here is the code:
>
>   http://forum.dlang.org/thread/ifg5ei$2qc7$1@digitalmars.com
>
> Ali

I attempted to create a sliceable forward range from an input 
range. I think I ran into a problem of keeping the buffer in sync 
when doing lookahead.

list2 = list1.save();

while(true) {
     list1.popFront();
     list2.popFront();

     assert(list1.front == list2.front);
}

What happens when your buffer needs to fill, how do you get the 
data in list 1 & 2? I'm not posing this question as impossible 
only something to make work.


More information about the Digitalmars-d-learn mailing list