Problem about lambda expressions

Tongzhou Li zhangsongcui at hotmail.com
Wed Mar 28 01:16:35 PDT 2012


On Tuesday, 27 March 2012 at 14:54:11 UTC, Artur Skawina wrote:
> 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

Yes, this is what I want to do. Thanks!


More information about the Digitalmars-d-learn mailing list