Returning an empty range of a given type

Idan Arye via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Sun May 17 05:07:10 PDT 2015


On Friday, 15 May 2015 at 03:47:46 UTC, rcorre wrote:
> On Friday, 15 May 2015 at 03:22:43 UTC, rcorre wrote:
>> On Thursday, 14 May 2015 at 14:57:26 UTC, Idan Arye wrote:
>>
>>> How about a more flexible solution?
>>>
>>> http://dpaste.dzfl.pl/2f99cc270651
>>
>> Neat, thanks!
>>
>
> The range I don't pick may be an expression that would fail, so 
> I tweaked it to:
> SelectRange!T selectRange(T...)(size_t index, lazy T ranges)
>
> Other than that, it seems to be just what I needed. Thanks 
> again!

Keep in mind that lazy arguments are actually delegates, which 
means they need the GC. If using the GC doesn't bother you you 
can use std.range.interfaces to wrap things up in an object: 
http://dlang.org/phobos/std_range_interfaces.html#InputRange


More information about the Digitalmars-d-learn mailing list