Getting the template name of a template instantiation

Ali Çehreli via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Mon Jun 27 10:15:50 PDT 2016


On 06/27/2016 09:54 AM, Lodovico Giaretta wrote:
> On Monday, 27 June 2016 at 16:40:09 UTC, Nordlöw wrote:
>> If I have a template parameter
>>
>>     E = S!int
>>
>> where
>>
>>     struct S(T) { S x; }
>>
>> how can I extract the template name part `S` from E`?
>>
>> Something like:
>>
>>     static assert(is(templateName!(S!int) == S));
>>
>> Is this already in Phobos somewhere?
>
> If I recall correctly, std.traits contains a TemplateOf trait, that
> should do exactly what you want.

Yes, isIntanceOf:

   https://dlang.org/phobos/std_traits.html#isInstanceOf

Ali



More information about the Digitalmars-d-learn mailing list