I have a geometry structure describing a point in N dimensions
template <typename T, std::size_t N>
class point : public std::array<T, N>
Among the many constructors / methods I'd like to add to this class, I cannot figure out how to build a variadic constructor. I've tried
template<typename ...Args>
point(Args&&...t) : std::array<T,N>(std::forward<Args>(t)...)
{
}
but that doesn't work
std::array<int,5> p1 = {0, 1, 1, 2, 3}; // OK
point<int,5> p2 = {0, 1, 1, 2, 3}; // ERROR
how can I define such a constructor ?
std::initializer_list?std::forwardand you have your original desired constructor.std::arrayis an aggregate and has no user defined constructors, so you must perform aggregate initialization.