int array[10] = {};
Please note if you want a more general way:
template <typename T, size_t N> T* endof(T (&pArray)[N]) { return &pArray[0] + N; }
To obtain:
std::fill(array, endof(array), x);
It should be mentioned that std::fill is just a wrapper around the loop you are trying to avoid, and = {}; can be implemented in such terms.
GManNickG
source share