Get template name
Dicebot
public at dicebot.lv
Tue Jul 30 03:45:24 PDT 2013
On Tuesday, 30 July 2013 at 06:45:31 UTC, JS wrote:
> void f()
> {
> pragma(msg, __FUNCTION__);
> }
>
> template t()
> {
> pragma(msg, __FUNCTION__);
> }
>
> void main(string[] argv)
> {
> readln();
> }
>
> the function displays main.f. The template displays nothing.
> I'd prefer it to display main.t! or something unique so I can
> use it as a hash.
1) Pragma's are printed upon instantiation. You need to use
something like alias _ = t!(); to force it.
2) You may workaround it by wrapping pragma in stub function.
Though I do agree that something like __ENCLOSING__ may be useful
(assuming it also covers aggregates)
More information about the Digitalmars-d-learn
mailing list