Possible Duplicate:
Programmatically create static arrays at compile time in C++
I have lots of data to be stored in a fixed array, with its elements depend on position. The value of each element can be calculated at compile time.
My code is almost like:
int fun(int p) // maybe constexpr
{
return 0x1<<p;
}
int a[17] = {
repeat_fun_from_0_to_16();
};
Since all of the value can be determined at compile time, there should be a way to do this, I guess.
I also checked out there's a repeat()
in boost.assignment, but don't know how to use it with this situation.