Interactive D?
Oskar Linde
oskar.lindeREM at OVEgmail.com
Tue Feb 26 06:45:02 PST 2008
Jarrett Billingsley wrote:
> "Oskar Linde" <oskar.lindeREM at OVEgmail.com> wrote in message
> news:fq126m$enh$1 at digitalmars.com...
>
>> Regarding stringof. The following is irritating, given:
>>
>> template A(T) { struct A {} }
>> template B(T) { struct A {} struct B {} }
>>
>> A!(int) a;
>> B!(int).B b;
>>
>> How do I reliably get the string representation of the type of a and b?
>>
>> There are two ways that I know of:
>>
>> 1. typeid(typeof(x)).toString
>> 2. typeof(x).stringof
>>
>> The problem is that the results are:
>>
>> 1A: test.A!(int).A WRONG
>
> This one is correct, as far as I can see. A!(int) a; is just sugar for
> A!(int).A a;.
Nope, if implicit template properties is in action, A!(int) is the only
valid way to refer to the template instance. If that weren't the case,
consider:
template A(T) { struct A { int A; }}
what is A!(int).A ?
And that reminds me that this (
http://d.puremagic.com/issues/show_bug.cgi?id=242 ) ancient bug is still
unresolved:
template A() { template A() { alias int A; }}
A!()!() x; // found '!' when expecting ';' following 'statement'
--
Oskar
More information about the Digitalmars-d
mailing list