Unexpected type names with template typedefs

Simen Kjaeraas simen.kjaras at gmail.com
Mon Apr 28 23:22:43 PDT 2008


On Tue, 29 Apr 2008 05:45:18 +0200, BCS <ao at pathlink.com> wrote:

> Reply to Simen,
>
>> struct foo(T)
>> {
>> T value;
>> }
>> template bar(T)
>> {
>> typedef foo!(T) bar;
>> }
>> void main(string[] args)
>> {
>> writefln((bar!(int)).stringof); // prints 'bar'
>> writefln((bar!(float)).stringof); // prints 'bar'
>> writefln((bar!(bar!(int))).stringof); // prints 'bar'
>> writefln((foo!(int)).stringof); // prints 'foo!(int)'
>> writefln((foo!(float)).stringof); // prints 'foo!(float)'
>> writefln((foo!(foo!(int))).stringof); // prints 'foo!(foo!(int))'
>> }
>> Should not the output of the first three be 'bar!(int)',
>> 'bar!(float)',  and 'bar!(bar!(int))'?
>>
>
> you might be getting a smaller case than what you want, namely the  
> typedef rater than the name of the template. this might be be related to  
> fully qualified names and such.

That's what I think as well. I'm just wondering if it is correct. Seeing as
the typedef maps to a template instantiation that would normally be called
bar!(Something), I'd expect the typedef to match that name.

-- Simen


More information about the Digitalmars-d-learn mailing list