mardi 3 mars 2015

variadic template for forward list initialization


Vote count:

0




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



point<int,5> p1 = {0, 1, 1, 2, 3}; // OK
std::array<int,5> p2 = {0, 1, 1, 2, 3}; // ERROR


how can I define such a constructor



asked 1 min ago

Amxx

476






variadic template for forward list initialization

Aucun commentaire:

Enregistrer un commentaire