Split range that has no length or slice?

Spacen Jasset via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Mon Nov 9 06:44:37 PST 2015

I can't seem to find a way of splitting a range of characters 
into lines unless the range has a length or can be sliced? This 
presumably is because i is a range of chunks, which cannot have a 
length or a slice. I do not see how to get anything else from the 
File object at the moment.

import std.stdio;
import std.string;

void printFile(Range)(Range i)
     foreach (l; lineSplitter(i)) {
         writefln("%d\n", l);

auto range(File f)
     const size_t someArbitrary = 4096;
     return f.byChunk(someArbitrary);

void main()
     File f = File("/etc/passwd");

     // std.string.lineSplitter(Flag keepTerm = KeepTerminator.no, 
Range)(Range r) if (hasSlicing!Range && hasLength!Range || 
     // test.d(21): Error: template instance 
test.printFile!(ByChunk) error instantiating

More information about the Digitalmars-d-learn mailing list