I try to create an std::initializer_list
of bind values, compile time using the following function.
However, I can't get it correctly.
template<class T, int N> auto b(T t) -> auto
{
if constexpr (N == 0) {
return std::initializer_list<????????>{ std::bind(t, 0) };
}
else {
return std::initializer_list { b<decltype(t), N-1>(t), std::bind(t, 0) };
}
}
All this is to avoid code like:
char F(int c) { return 42; /* do something with c or course */ }
// ....
auto fs = { std::bind(F, 0),
std::bind(F, 1),
std::bind(F, 2),
std::bind(F, 3),
std::bind(F, 4),
std::bind(F, 5) /*, etc ...*/};
Is there anyone who can guide me towards a feasible solution?