I would like to write a class that takes a size N (> 0) and a variable number of arguments (>= N). It should have a constructor that takes N arguments and a member std::tuple which has the same type:
template <size_t N, typename... Args>
struct Example {
// A constructor taking N parameters of type Args[N], initializing the member tuple
// (e.g. param 1 has type Args[0], param 2 has type Args[1], ...,
// param N has type Args[N-1])
// A tuple with N elements, each corresponding to Args[N]
// (e.g. std::tuple<Args[0], ..., Args[N-1]>)
//For instance Example<3, int, float, int, bool> should result in
constexpr Example(int a, float b, int c): t(a, b, c) {}
std::tuple<int, float, int> t;
}
In general: Is this possible? If not are there viable alternatives? Why does/ doesn't this work? I'm using C++20.