template forward reference

Sebastian Beschke s.beschke at gmx.de
Sat Nov 3 15:26:40 PDT 2007


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

C. Dunn schrieb:
> 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?

Does anyone know if this problem has been resolved in the meantime? I'm
having similar error messages with all my templates after upgrading
rebuild. Is that an old problem or a new problem?

Sebastian
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.7 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFHLPWgKb/1n5A2TAMRApWeAJ433N8pE4nrArZBmFqEuUwuAM+RHgCfXn7S
d16Ay3HwzepN52b8AdImLU0=
=yzOF
-----END PGP SIGNATURE-----



More information about the Digitalmars-d mailing list