Question about template instantiation scope

Edward Diener eddielee_no_spam_here at tropicsoft.com
Sat Mar 22 18:09:32 PDT 2008


In the section about template instantiation scope, the below example is 
given of illegality:

"module a
template TFoo(T) { void bar() { func(); } }
module b
import a;
void func() { }
alias TFoo!(int) f; // error: func not defined in module a"

 From this I assume that a template which refers to some type or object 
which is not in the module of the template declaration must import the 
module where the type or object is defined in order to be instantiated 
at all. For example:

"module c
void func() { }
module a
import c;
template TFoo(T) { void bar() { func(); } }
module b
import a;
void func() { }
alias TFoo!(int) f; // legal"

Is this correct ?



More information about the Digitalmars-d mailing list