On Thursday, 23 February 2017 at 18:35:29 UTC, Profile Anaysis
wrote:
[...]
option 1 is the one I was shooting for. does the static if
(audio) just check for the existence of audio, or does it also
check to see if audio is true as well?
Yes, but it checks at compile time. So the code will be
evaluated by the compiler and if audio is true, it will only
compile in the code in the if block.
e.g,
static if (audio) { do something }
will be identical, in the binary, to
do something
if audio is true.
The static if is an if statement and works like any ordinary if
statement, but since you are using static(known at compile
time) information then static if can actually be
computed/evaluated at compile time(since all the inputs are
know and cannot be changed)
Or to make it simple
static if (audio) { do somethng }
is the same thing as
#if audio
do something
#endif
in C and C++.