Metaprogramming, generate argument list.

ciechowoj via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Mon Aug 22 15:01:51 PDT 2016


Is it possible to generate an argument list that contains 
pointers to local variables at compile time?

For example, consider following code:

template Repeat(alias int N, alias variable)
{
     // Magic

     alias Repeat = /* Even more magic */;
}

void foo(int* x, int* y, int* z)
{
     // [...]
}

void fun()
{
     int bar = 42;

     foo(Repeat!(3, bar)); // want to replace it with &bar, &bar, 
&bar
}


More information about the Digitalmars-d-learn mailing list