simple static if / traits question...

WhatMeWorry via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Wed Feb 22 13:27:47 PST 2017



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 );


This works, but I thought there might be a simpler way. For 
instance,
after perusing std.traits, I thought I would find something like
isPresent(audio) or isSymbol(audio) templates.

Or am I being obtuse here?

Thanks.


More information about the Digitalmars-d-learn mailing list