www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - Implicit instantiation of template constants?

When replacing macros in C, this pattern is useful:

template MAKE_ID(char a, char b, char c, char d)
   const int MAKE_ID = ((a)<<24) | ((b)<<16) | ((c)<<8) | (d);

const int TEST_ID = MAKE_ID!('A','B','C','D');

Would it be possible to have these implicitly instantiated?  That would 
make it look and feel exactly like the C macro, which is nice when the 
library in question is just a set of D bindings.  You don't need to 
explain the use of the question mark in the docs, etc.

And would it be possible to allow such templates to be used to 
initialize enums?  That's currently an error.
Feb 06 2007