Conditional Compilation Multiple Versions

bitwise via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Sat Jun 13 09:26:15 PDT 2015


On Sat, 13 Jun 2015 12:20:40 -0400, ketmar <ketmar at ketmar.no-ip.org> wrote:

> On Sat, 13 Jun 2015 13:49:49 +0000, anonymous wrote:
>
>> Taking it one step further:
>>
>> template Version(string name)
>> {
>>      mixin("
>>          version("~name~") enum Version = true;
>>          else enum Version = false;
>>      ");
>> }
>>
>> static if(Version!"One" || Version!"Two")
>> {
>>      ...
>> }
>
> very elegant.

Elegant indeed, but I think my pull request would be frowned upon if I  
tried to use this in druntime.

   Bit


More information about the Digitalmars-d-learn mailing list