Initializing "two-dimensional" compile-time enum

Uranuz neuranuz at gmail.com
Sun Nov 24 11:09:46 PST 2013


As far as I understand I can't use immutable values as template 
arguments. It's what I need in my code. I'll give an example.

//---------------
import std.stdio;

immutable(string[int][string]) pohodEnumValues;

shared static this()
{
     pohodEnumValues = [
	"vid": [ 3: "skiing", 5: "rafting", 7: "jumping" ],
	"ks": [ 1: "first", 2: "second", 3: "third" ],
	"prepare": [ 1:"planning", 3:"preparing", 5:"complete" ]
	];
}

//Some template method
void foo(string arg)()
{ //Some actions here
	
}

void main()
{
	foreach( name, item; pohodEnumValues )
	{	foo!(name)(); //I need name at compile time here
	}
}
//-----------------

Because we have only compile time foreach over tuple this is not 
working. Can someone give an advice, please?


More information about the Digitalmars-d mailing list