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.

Reply via email to