Counting at compile-time
DLearner
bmqazwsx123 at gmail.com
Sun Jan 26 15:42:44 UTC 2025
Suppose we have
```
enum Count = 0;
static if (<Compile-time evaluable cond-1>)
...
enum Count = Count + 1; // is disallowed
else
static if (<Compile-time evaluable cond-2>)
...
enum Count = Count + 1; // is disallowed
else
```
and the objective is to determine (at compile time) the number of
times cond-1 or cond-2 is triggered (perhaps for setting size of
a fixed array).
So answer is zero, 1 or 2.
But how to get that value into Count?
More information about the Digitalmars-d-learn
mailing list