Suppose that I want to declare a local static constant array, but I don't know its initializer values in compile time, and those have to be calculated first. For example, I have an array int p[100]
. I write a loop to fill it with first 100 prime numbers. After those are calculated, I define a static const int primes[100]
which has to be initialized by the values of p
. How can I do this?
P.S. The question of "why I want to declare a local static const object?" may not have a satisfactory answer, but I think this is not the case here.
P.S.S. I mentioned the prime numbers just as an example. That is not the point.
P.S.S.S. Let's say p
has 1000000 members. Then the solution suggested by user2079303 surely deserves more upvotes.