On Monday, 25 July 2016 at 22:27:11 UTC, Cauterite wrote:
On Monday, 25 July 2016 at 02:15:12 UTC, Gorge Jingale wrote:
Is there a static ternary if?

(A == B) ? C : D;

for compile type that works like static if.

You can pretty easily make your own;

  template staticIf(bool cond, alias a, alias b) {
    static if (cond) {
      alias staticIf = a;
    } else {
      alias staticIf = b;
    };
  };

The drawback is that there's no 'short-circuiting'; a and b are both evaluated.

Cool, that would work. I don't think the lazy evaluation is a problem at compile time? Just makes for longer times, but should be pretty minuscule.

Reply via email to