Get template and its instantiation parameters

Christopher Wright dhasenan at gmail.com
Wed Oct 7 15:38:26 PDT 2009


BCS wrote:
> Hello Michal,
> 
>> If one has a template instance, is it possible to get template name
>> and parameter type that was used for instantiating, at compile time?
>>
>> consider:
>>
>> class List (T) {}
>>
>> List!(int) lst;
>> Foo (lst);
>> I want to create such template Foo which prints:
>> List!(int)
>> List
>> int
> 
> You could try parsing T.stringof at compiletime to extract the parts you 
> need.

No, you can't. You can try parsing demangle!(T.mangleof) at compiletime 
to extract the parts you need. stringof is a morass of inconsistency and 
partial information. Whenever a template gets within a mile of a type, 
all bets are off.


More information about the Digitalmars-d-learn mailing list