On Fri, Apr 18, 2014 at 01:30:00AM +0000, Hannes Steffenhagen via Digitalmars-d-learn wrote: > 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 that proved to be the least hassle to use for my > simple test cases.
Please note that InputRange, as defined in std.range, is a *wrapper* class, intended for use in handling runtime polymorphism of ranges. It is not to be confused with the *concept* of an input range, which can be any type that provides the range API. The general practice in D is to use a template parameter for functions that take range parameters, so that the function can be instantiated for any type that satisfies the range API (including InputRange). InputRange generally is used by the code that *creates* the range, when it needs to be able to switch between different range types at runtime. T -- This sentence is false.
