www.digitalmars.com         C & C++   DMDScript  

D - Template-aliases and typedefs

reply Matthias Becker <Matthias_member pathlink.com> writes:
Just an idea: What about template-aliases and typedefs

alias(T) OherTemplate(T, T, int) MyAlias;

MyAlias!(double) foo;
Jan 27 2004
parent reply Andy Friesen <andy ikagames.com> writes:
Matthias Becker wrote:
 Just an idea: What about template-aliases and typedefs
 
 alias(T) OherTemplate(T, T, int) MyAlias;
 
 MyAlias!(double) foo;
 

The 'class Foo(T)' template form is a shorthand for: template Foo(T) { class Foo { ... } } So, if you want a template typedef, you just do: template MyAlias(T) { alias OtherTemplate!(T, T, int) MyAlias; } MyAlias!(double) foo; Kinda cool that D gets things that haven't even made it into C++, merely as a side effect of its design. :) -- andy
Jan 27 2004
parent Matthias Becker <Matthias_member pathlink.com> writes:
The 'class Foo(T)' template form is a shorthand for:

template Foo(T) {
    class Foo {
       ...
    }
}

So, if you want a template typedef, you just do:

template MyAlias(T) {
    alias OtherTemplate!(T, T, int) MyAlias;
}

MyAlias!(double) foo;

Kinda cool that D gets things that haven't even made it into C++, merely 
as a side effect of its design. :)

Jan 27 2004