Alias parameters in nested templates

Tomek Sowiński just at ask.me
Thu Feb 11 11:10:32 PST 2010


I've been playing with templates recently and there's something I don't  
quite get.

template Outer() {
     template Inner(alias param) {
         alias param Inner;
     }
}

void main() {
     long d;
     Outer!().Inner!(d) = 4; // fails
}

Error: template instance cannot use local 'd' as parameter to non-global  
template Inner(alias param)

Why is it OK to pass aliases to local variables to a normal (global)  
template, and not OK to a nested one? I'd appreciate a counter-example of  
sth bad happening in the forbidden case.


Tomek


More information about the Digitalmars-d-learn mailing list