[Issue 18558] Template alias spec incomplete
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Mon Mar 5 16:26:32 UTC 2018
https://issues.dlang.org/show_bug.cgi?id=18558
--- Comment #4 from Jonathan Marler <johnnymarler at gmail.com> ---
Maybe a better description...
template "alias" parameters can accept "symbols" and "values". If a symbol is
passed to the template, i.e.
MyTemplate!someSymbol
Then the symbol is passed directly to the template without being treated as an
expression to evaluate. Even if the symbol is a function, the function is not
called and then passed to the template, the function symbol is passed to it.
However, if an "non-symbol" expression is passed to the template, then the
expression is evaluated at "compile time" and the return value passed to it,
i.e.
MyTemplate!42
MyTemplate!(40 + 2)
enum x = 40;
MyTemplate!(x + 2)
auto return42() { return 42; }
MyTemplate!(return42())
All these represent the same template instantiation.
--
More information about the Digitalmars-d-bugs
mailing list