template forward reference

C. Dunn cdunn2001 at gmail.com
Mon Jul 30 18:59:27 PDT 2007


This works:
<code>
class Foo(T){
  int bar(){
    return A.hi();
  }
};

class A{
  static int hi(){
    return 0;
  }

  F!(char) x;
};
</code>

But if I split these into 2 separate modules, where each module imports the other, then the module with class A does not compile:
  Error: forward reference to 'Foo!(char)'
  Error: F is used as a type

If I make the template class a regular class, it compiles fine.  I understand that cyclic template specializations could create problems, but I don't see why moving a template into a separate module fails.  This works easily in C++ by just forward-declaring class A.

Why does this not work?  Are there plans to support it in the future?



More information about the Digitalmars-d mailing list