Template question

BCS BCS at pathlink.com
Wed Oct 4 18:29:58 PDT 2006


Chad J > wrote:
> Sean Kelly wrote:
> 
>> Chad J > wrote:
>>
>>> I'm trying to write a template that, when instantiated, gives a value 
>>> that is the same as the last time it was instantiated plus one.
>>
>>
>>
>> I don't think this is possible.  Once a template is evaluated that's 
>> it.  Future references to a template do not cause a re-evaluation.
>>
>>
>> Sean
> 
> 
> Oh, bummer.  Is there another way to do what I want to do at 
> compile-time, besides just manually writing the numbers in?

It would require a new feature but...

<code>
enum Root{}

enum foo : Root{a}	
// a is distinct from all values in types deriving from Root
foo.a;

enum bar : Root{a}
// a is distinct from all values in types deriving from Root
bar.a
</code>

Implementing this would be a pain though (putting the enums in different 
  files...)  :P



More information about the Digitalmars-d-learn mailing list