July 07, 2004 Template bug | ||||
---|---|---|---|---|
| ||||
Compile these two files together and everything is ok. Compile them separately and there is a linker error. test.obj(test) Error 42: Symbol Undefined _D5temp129foo_i__20__D4test7thefuncFiZb3fooFiZb --- errorlevel 1 //---- test ----- import temp1; bool thefunc(int v) { return v == 3; } void main(char[][] argv) { bar!(int,thefunc)(5,3); } //---- temp1 ----- template foo(Type,alias Func) { bool foo(Type v) { return Func(v); } } template bar(Type,alias Func) { void bar(Type v, Type a) out { assert(foo!(Type,Func)(v)); } body { v = a; } } //---- test.d ----- import temp1; bool thefunc(int v) { return v == 3; } void main(char[][] argv) { bar!(int,thefunc)(5,3); } |
Copyright © 1999-2021 by the D Language Foundation