Unable to instantiate template with same name as function

Shriramana Sharma via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Wed Mar 2 22:12:13 PST 2016


Hello. I have a function I want to make CTFE-able as a template.

string ta(string s) { return s ~ "1"; }
template ta(string s) { enum ta = ta(s); }
void main() { string s = ta!"s"; }

Compiling the above I get the errors:

<src>(2): Error: forward reference of variable ta
<src>(3): Error: template instance <src>.ta!"s" error instantiating

Please clarify what I am doing wrong? Thanks!

-- 
Shriramana Sharma, Penguin #395953


More information about the Digitalmars-d-learn mailing list