I have a class where I'd like to supply it with an InputRange!string. Yet, for the life of me I can't seem to pass to it a File.byLine, even though the documentation states it's an InputRange.
class Foo {
private InputRange!string source;
this(InputRange!string s) {
source = s;
}
// do stuff with it
}
new Foo(File("stuff.txt").byLine);
// Error constructor Foo.this(InputRange!string) is not callable using argument types (ByLineImpl!(char, char))
I have to believe this is possible. I'm thinking maybe I need to template the constructor with something like:
this(R)(R s) if (isInputRange!R)
But, then I seem to have 2 problems:
- I haven't ensured it's an InputRange!string
- I've just punted the problem up a level, because my member variable doesn't work.
Any help appreciated. Thanks!