I'm not a D programmer though so I could be wrong.
Look up static if - AST manipulation in native D code.