parameter pack to inputRange

Dicebot via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Thu May 5 23:08:24 PDT 2016


Unless parameter list is very (very!) long, I'd suggest to simply 
copy it into a stack struct. Something like this:

auto toInputRange (T...) (T args)
{
     struct Range
     {
         T args;
         size_t index;

         T[0] front () { return args[index]; }
         void popFront () { ++index; }
         bool empty () { return index >= args.length; }
     }

     return Range(args, 0);
}


More information about the Digitalmars-d-learn mailing list