I have an array whose size is set using a compile-time constant (a pre-processor #define
in my case). I need to initialize it using consecutive numbers at compile-time. How can I do this?
Simplified example:
#define ARR_SZ 5
struct C {
C(int a) : a(a) {}
int a;
};
C arr[ARR_SZ] = {{0},{1},{2},{3},{4}}; // This needs to adapt to any number
I can use C++11, but not newer (although I would be interested to learn of newer techniques even if I can't use them for this project)