How to check for combinations of versions
Blatnik
blatblatnik at gmail.com
Wed May 5 15:03:16 UTC 2021
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 feature.
} else {
// Do something less cool but portable.
}
```
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 {
enum Cool_Feature_Supported = false;
}
...
void do_something_cool() {
static if (Cool_Feature_Supported) {
...
} else {
...
}
}
```
More information about the Digitalmars-d-learn
mailing list