How to stringify a template instantiation expression?

Yuxuan Shui yshuiv7 at gmail.com
Thu Mar 1 16:46:30 UTC 2018


On Wednesday, 28 February 2018 at 15:49:25 UTC, aliak wrote:
> On Wednesday, 28 February 2018 at 15:09:56 UTC, Yuxuan Shui 
> wrote:
>> For a template instantiation expression like A!(B, C!(D, E)), 
>> I want to get a string "A!(B, C!(D, E))", better if A, B, C, 
>> D, E is replaced by fully qualified name.
>>
>> Is this possible?
>
> A!(B, C!(D, E)).stringof I guess. Will print the former.
>
> There's a Learn forum as well btw :)
>
> Cheers

Did you actually try that? With dmd 2.079-rc1, this:

template A(T...) {}
struct B {}
struct D {}
struct E {}
template C(T...) {}
pragma(msg, (A!(B, C!(D, E))).stringof);

Prints:

A!(B, __T1CTS2ax1DTSQh1EZ)

When compiled


More information about the Digitalmars-d mailing list