There are several ways. One way is to add the array conditionally using the ternary operator:
static const country[] countries = [ country("Iceland", 800), country("Australia", 309), ] ~ (include_germany ? [country("Germany", 233254)] : []) ~ [ country("USA", 3203) ];
You can also write a function that calculates and returns an array, and then initializes the const value with it. The function will be evaluated at compile time (CTFE).
source share