simple static if / traits question...

Era Scarecrow via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Wed Feb 22 14:11:47 PST 2017


On Wednesday, 22 February 2017 at 21:27:47 UTC, WhatMeWorry wrote:
>
>
> I'm doing conditional compilation using static ifs like so:
>
> enum bool audio       = true;
>
>
>
> // if audio flag is present and set to true, add to code build
>
> static if ( (__traits(compiles, audio)) && audio)					
>     playSound(soundSys, BLEEP );

  I think you're thinking too deeply on this. During optimization 
branches of if statements that always evaluate to false are 
compiled out.


More information about the Digitalmars-d-learn mailing list