Adding a read primitive to ranges
Freddy via Digitalmars-d
digitalmars-d at puremagic.com
Mon May 4 18:40:26 PDT 2015
On Monday, 4 May 2015 at 00:07:27 UTC, Freddy wrote:
> Would it be a bad idea to add a read primitive to ranges for
> streaming?
> ----
> struct ReadRange(T){
> size_t read(T[] buffer);
> //and | or
> T[] read(size_t request);
>
> /+ empty,front,popFront,etc +/
> }
> ----
Also if so, What about adding a default read for input ranges.
Something like
----
typeof(range.front)[] read(R)(ref R range,size_t amount){
auto data=new typeof(range.front)[amount];
/+... read into data ...+/
return data[0..actual_amount];
}
----
More information about the Digitalmars-d
mailing list