Typed variadic template syntax?
Timon Gehr
timon.gehr at gmx.ch
Thu Jan 30 07:28:33 PST 2014
On 01/30/2014 03:08 PM, Ilya Yaroshenko wrote:
>>
>> 2) `foreach` creates it's own scope. This won't work:
>> foreach(i; TypeTuple!(1,2,3)){
>> mixin("int num"~i.stringof~";");
>> }
>> num1=1;
>> num2=2;
>> num3=3;
>> writeln(num1,num2,num3);
>
> ...
> 2) no. This should work for compile time foreach and TypeTuples. There
> are many examples in source code of Phobos.
The following code fails to compile:
import std.typetuple, std.stdio;
void main(){
foreach(i; TypeTuple!(1,2,3)){
mixin("int num"~i.stringof~";");
}
num1=1;
num2=2;
num3=3;
writeln(num1,num2,num3);
}
More information about the Digitalmars-d
mailing list