www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - Public template types

Sometimes I have to make a template type argument visible inside 
the instantiated type:


struct Foo(T_) {
     alias T = T_;
}
void main() {
     Foo!int f;
     static assert(is(f.T == int));
}


A little of syntax sugar could do the same, avoiding the need for 
a new name as "T_":

struct Foo(public T) {}

Do you like?

Bye,
bearophile
Nov 03 2013