Re: Static ternary if

2016-07-26 Thread Cauterite via Digitalmars-d-learn
On Tuesday, 26 July 2016 at 00:54:59 UTC, Michael Coulombe wrote: If that's ok, then try out std.traits.Select or std.traits.select: https://dlang.org/phobos/std_traits.html#Select Damn, I looked real hard for that template, I knew it existed. I expected it to be in std.meta though.

Re: Static ternary if

2016-07-25 Thread Michael Coulombe via Digitalmars-d-learn
On Monday, 25 July 2016 at 22:57:05 UTC, Gorge Jingale wrote: 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

Re: Static ternary if

2016-07-25 Thread Gorge Jingale via Digitalmars-d-learn
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,

Re: Static ternary if

2016-07-25 Thread Cauterite via Digitalmars-d-learn
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;

Re: Static ternary if

2016-07-25 Thread lqjglkqjsg via Digitalmars-d-learn
On Monday, 25 July 2016 at 05:00:23 UTC, Ali Çehreli wrote: On 07/24/2016 07:15 PM, Gorge Jingale wrote: Is there a static ternary if? (A == B) ? C : D; for compile type that works like static if. The way to force an expression at compile time is to use it for something that's needed at

Re: Static ternary if

2016-07-24 Thread Ali Çehreli via Digitalmars-d-learn
On 07/24/2016 07:15 PM, Gorge Jingale wrote: Is there a static ternary if? (A == B) ? C : D; for compile type that works like static if. The way to force an expression at compile time is to use it for something that's needed at compile time. For example, you can initialize a manifest