January 25, 2006 . is still required for recursion when a template alias is used. | ||||
---|---|---|---|---|
| ||||
If you insert a dot before the recursive factorial call, it will work correctly. ----------- template factorial(int n) { static if (n<2) const int factorial = 1; else const int factorial = n * factorial!(n-1); } template rhino(alias hippo) { const int rhino = hippo!(2); } const int lion = rhino!(factorial); -------------- |
February 05, 2006 Re: . is still required for recursion when a template alias is used. | ||||
---|---|---|---|---|
| ||||
Posted in reply to Don Clugston Attachments: | Don Clugston schrieb am 2006-01-25: > If you insert a dot before the recursive factorial call, > it will work correctly. > > ----------- > template factorial(int n) > { > static if (n<2) const int factorial = 1; > else const int factorial = n * factorial!(n-1); > } > > template rhino(alias hippo) > { > const int rhino = hippo!(2); > } > > const int lion = rhino!(factorial); > -------------- Added to DStress as http://dstress.kuehne.cn/run/t/template_26_A.d http://dstress.kuehne.cn/run/t/template_26_B.d Thomas |
Copyright © 1999-2021 by the D Language Foundation