Re: How to check for combinations of versions

2021-05-05 Thread Blatnik via Digitalmars-d-learn
On Wednesday, 5 May 2021 at 15:25:31 UTC, Paul Backus wrote: However, if you really want something more expressive, and are confident in your ability to use the extra power responsibly, it is possible to work around these limitations: template hasVersion(string identifier) { mixin(

Re: How to check for combinations of versions

2021-05-05 Thread Dennis via Digitalmars-d-learn
On Wednesday, 5 May 2021 at 15:03:16 UTC, Blatnik wrote: Is there any way to check for multiple conditions in a `version` statement? No, and that's by design to discourage complex version logic. The recommended approach is: ```D version (Version_A) version = Cool_Feature_Supported; version (Ve

Re: How to check for combinations of versions

2021-05-05 Thread Paul Backus via Digitalmars-d-learn
On Wednesday, 5 May 2021 at 15:03:16 UTC, Blatnik wrote: Currently I resort to something like this, but I'm curious if there's a nicer way to do it. ```D version (Version_A) { enum Cool_Feature_Supported = true; } else version (Version_B) { enum Cool_Feature_Supported = true; } else { enu

How to check for combinations of versions

2021-05-05 Thread Blatnik via Digitalmars-d-learn
Is there any way to check for multiple conditions in a `version` statement? For example, my platform may have `Version_A` and `Version_B`, and both versions provide some shiny feature I want to use. Is there some nice way to write: ```D version (Version_A || Version_B) { // Use the cool fe