Unique IDs for each template instantiation at compile-time?

Weasel weaselcat at gmail.com
Wed Dec 18 15:01:03 PST 2013


I was wondering if it was possible to generate unique(in order) 
IDs for each template instantiation of a class at compile-time.

A short example of what I'm trying to do:

static int counter = 0;
class A(T)
{
     enum id = counter++;
}
class B : A!B
{
}

Ofcourse, this doesn't compile because the "counter" variable 
can't be read at compile-time.


More information about the Digitalmars-d-learn mailing list