Problem about lambda expressions

Artur Skawina art.08.09 at gmail.com
Tue Mar 27 07:53:57 PDT 2012


On 03/27/12 15:52, Tongzhou Li wrote:
> Oh, I also tried:
>     void seq_apply(Params..., Args...)(void delegate(Params) func, Args args)
> But I got a error:
>     variadic template parameter must be last
> Does it mean that there can only be one variadic template parameter? How to fix it?

I'm not sure what exactly you're trying to do, but maybe this will help:

void seq_apply(Func, Args...)(Func func, Args args) {
        import std.traits;
        alias ParameterTypeTuple!Func Params;
        enum ArgNum = Params.length-1;
        func(args[0], args[1 .. ArgNum + 1]);
        static if (args.length > ArgNum + 1) {
                seq_apply(func, args[ArgNum + 1 .. args.length]);
        }
}

artur


More information about the Digitalmars-d-learn mailing list