Re: Named template constraints

2014-04-22 Thread Hannes Steffenhagen via Digitalmars-d-learn
Not sure what InputRange is defined as atm, but I don't think anything should have to define init to be a valid inputrange.

Re: What's the current phobos way to define generic data sources and sinks?

2014-04-17 Thread Hannes Steffenhagen via Digitalmars-d-learn
I've never said anything about inheriting from InputRange, just that I'd take an InputRange as a parameter. Anyway I changed my signature to Result parse(T)(T lines) if(isInputRange!T && is(ElementType!T == string)); Still not sure if that's the best way to do it, but it definitely is the one th

Re: What's the current phobos way to define generic data sources and sinks?

2014-04-17 Thread Hannes Steffenhagen
I wanna write a parser that can read the input text from an arbitrary source. That's going to be files for most of the time, but I don't want to unnecessarily limit it. It's a line based format, so I supposed InputRange!string would do in this case?

What's the current phobos way to define generic data sources and sinks?

2014-04-16 Thread Hannes Steffenhagen
I've looked at std.stream, but it says in big red scary letters that I probably shouldn't be using it. Is there a suitable replacement? If not, I'd just roll my own and provide a couple of templates to automatically generate wrappers for them.