Idiom for initializing an std::array using a generator function taking the index?
Suppose I have a function T foo(size_t i)
, And I want to construct an object arr
of type std::array<T, N>
such that arr[i] == foo(i)
. I would like a solution which works even when T
is not default-initializable .