how to get fully qualified name of a template function (if possible at CT)

timotheecour thelastmammoth at gmail.com
Fri Aug 24 23:16:09 PDT 2012


how to get fully qualified name of a template function?
In the code below I want to get "util.mod.mymethod!(double)"
I tried everything (see below) to no avail, it just returns 
"mymethod";
The closest I get is demangle(mangledName!(fun)), which shouldn't 
be hard to convert to what I want, but demangle is runtime, not 
compile time.

Ideally, fullyQualifiedName should do that, but currently fails. 
(btw I have a fix for another bug with fullyQualifiedName with 
non-templated functions which I can post shortly).

----
module util.mod;
import std.stdio;
import std.traits;
import core.demangle;

void mymethod(T)(){}
void main(){ fun_aux!(mymethod!double);}
void fun_aux(alias fun)(){
	pragma(msg,fun);
	writeln(fun.stringof);
	writeln(__traits(identifier,fun));
	writeln(__traits(identifier,__traits(parent,fun)));
	pragma(msg, mangledName!(fun));
	writeln(demangle(mangledName!(fun)));
	//pragma(msg, demangle(mangledName!(fun)));//CT error:demangle 
is runtime
	//writeln(fullyQualifiedName!fun);//CT error	
----



More information about the Digitalmars-d-learn mailing list