Variadic template arguments unpacking

TommiT tommitissari at hotmail.com
Sat Jul 6 09:40:24 PDT 2013


On Saturday, 6 July 2013 at 16:15:52 UTC, Max Strakhov wrote:
> Thanx for all your help, i just solved the problem with mixins 
> like this:
>
> string res = "";
> for(i, rev v; args)
>     res ~= string.format(", f(args[%d]).val()");
> mixin("return G(" ~ res ~ ");");
>
> Only without any actual looping and variables, so compiler 
> could deal with it.

printf("...", ForEach!(val => conv(val).c_str())(values).tuple);

...would have done exactly the same as C++:

printf("...", conv(values).c_str()...);

...does (barring it makes a temporary struct which holds one 
field for each of those converted const char pointers, but the 
compiler can optimize it away).


More information about the Digitalmars-d-learn mailing list