June 23, 2004 Other weird template alias bug | ||||
---|---|---|---|---|
| ||||
The following code recurses (printing 'int' over and over) until the stack overflows: struct Empty; template TypeList(T, R) { struct TypeList { alias T Type; alias R Rest; } } template Blah(A, alias B, alias C) { void Blah() { typeid(C.Type).print(); .Blah!(A, B, C.Rest)(); } } template Blah(A, alias B, C : Empty) { void Blah() { printf("Empty!\n"); } } alias TypeList!(int, TypeList!(float, TypeList!(char, Empty))) TL; int main() { Blah!(Empty, main, TL)(); return 0; } Changing the definition of TypeList to: template TypeList(T, R) { alias T Type; alias R Rest; } Causes an illegal operation and the error messages: template instance TypeList!(float,TypeList_aS6ttest25Empty) does not match any template declaration template instance TypeList!(float,TypeList_aS6ttest25Empty) cannot resolve forward reference (that's it for now. Honest) -- andy |
Copyright © 1999-2021 by the D Language Foundation