I have the following class:
const unsigned E = 256;
class A {
public:
static const unsigned x[E];
...
}
and I want to initialize x as follows:
const unsigned A::x[E] = { 1, 2, 3, ..., E };
The above assignment seems to be trivial for now. But, the point is to initialize the value of array x based on the index. A quick try seems to tell me that even with c++11 this isn't possible.
Any input?
Thanks.
std::iotamay suit your needs...std::integer_sequence, but it will not be available until C++14. en.cppreference.com/w/cpp/utility/integer_sequence