Recursive template solution:
// recursive helper struct
template <int n, int First, int ...Rest>
struct helper {
static void funcImpl(std::array<bool, SIZE>& temp) {
temp[First] = true;
helper<n - 1, Rest...>::funcImpl(temp);
}
};
// partial specialization to catch base case
template <int First>
struct helper<0, First> {
static void funcImpl(std::array<bool, SIZE>& temp) {
temp[First] = true;
}
};
template <int ...Args>
std::array<bool, SIZE> func() {
std::array<bool, SIZE> b = {}; // 0 inititalize array
helper<sizeof...(Args) - 1, Args...>::funcImpl(b);
return b;
}
EDIT: A super simplified version inspired by iavr's solution:
template <int... A>
std::array<bool, SIZE> func() {
std::array<bool, SIZE> b = {};
auto values = {A...};
std::for_each(values.begin(), values.end(), [&](int n){b[n] = true;});
return b;
}