digitalmars.D.bugs - Template instant not created (linker error)
- Nick <Nick_member pathlink.com> Aug 05 2004
The following compiles but does not link:
# import std.stdio;
#
# template Bar(Y)
# {
# void Bar(Y param) {writefln("The parameter was: ", param);}
# }
#
# template Foo(alias X)
# {
# alias Bar!(typeof(X)) Foo;
# }
#
# void unused()
# {
# float f;
# // Uncomment this line and the linker error disappears
# // Bar!(typeof(f))(f);
# }
#
# void main()
# {
# float f = 1.2;
#
# // A really ugly kind of implicit instantiation :-)
# mixin Foo!(f); Foo(f);
# }
Instantiating the template explicitly (even in another scope in an uncalled
function) solves the problem.
Nick
Aug 05 2004








Nick <Nick_member pathlink.com>