Thread overview
Template-aliases and typedefs
Jan 27, 2004
Matthias Becker
Jan 27, 2004
Andy Friesen
Jan 27, 2004
Matthias Becker
January 27, 2004
Just an idea: What about template-aliases and typedefs

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

MyAlias!(double) foo;



January 27, 2004
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
January 27, 2004
>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. :)
>
Right. Thanks.