March 24, 2004 Constant specialization in templates | ||||
---|---|---|---|---|
| ||||
It would be nice to be able to do something like this:
template Test(T) { int T; }
template Test(const T) { const int T; }
alias Test!(int) testDyn;
alias Test!(10) testConst;
At the moment the only work around I can think of is something like this:
struct intD { int x; } //Dynamic
struct intC { const int x = 10; } //Static
template Test(T) { int T; }
alias Test!(intD) testDyn;
alias Test!(intC) testConst;
It would be particularly useful for things like templated structs because you would be able to have things staticly compiled which would save memory and improve performace. I could see something like this being used for Matthews proposed ranges.
--
-Anderson: http://badmama.com.au/~anderson/
|
Copyright © 1999-2021 by the D Language Foundation