:? in templates

Bill Baxter wbaxter at gmail.com
Wed Nov 18 03:10:57 PST 2009


Didn't this used to work?

template factorial(int i) {
    enum factorial = (i==0) ? 1 : i*factorial!(i-1);
}

With DMD 2.036 I'm getting:
  Error: template instance factorial!(-495) recursive expansion

Seems like it expands both branches regardless of the condition.
And seems to me like it shouldn't.

--bb



More information about the Digitalmars-d mailing list