static assert(version(x)) ?
Dennis
dkorpel at gmail.com
Tue Nov 26 12:51:41 UTC 2019
On Tuesday, 26 November 2019 at 10:24:00 UTC, Robert M. Münch
wrote:
> How can I write something like this to check if any of a set of
> specific versions is used?
```
version(a) {}
else version(b) {}
else version(c) {}
else {
static assert(0, "only versions a, b and c are supported");
}
```
```
version(a) version = supported;
version(b) version = supported;
version(c) version = supported;
version(supported) {
// good to go
} else {
static assert(0, "not a supported version");
}
```
> static assert(!(version(a) | version(b) | version(c)):
That seems to be the opposite of what you describe.
If you want that, then:
```
version(a) static assert(0, "version a not supported");
version(b) static assert(0, "version b not supported");
version(c) static assert(0, "version c not supported");
```
More information about the Digitalmars-d-learn
mailing list