I wrote the following code to create a class with the construct that takes as arguments a variable number (N) of integer plus two double as follow:
#include <cstdio>
#include <cstdlib>
#include <vector>
#include <array>
template <std::size_t N>
class point_t {
public:
std::vector<int> values;
template<typename ... Args>
point_t(Args ... args, double distance, double value) {
std::array<int , N> list = {(args)...};
for(std::size_t i=0; i<N; ++i) values[i] = list[i];
}
};
int main(int argc, char *argv[]) {
point_t<4> test(1, 2, 3, 4, 3.0, 6.7);
return 0;
}
The compiler return the following error:
No matching constructor for initialization of 'point_t<4>'
Candidate constructor not viable: requires 2 arguments, but 6 were provided
What I'm missing?
Aucun commentaire:
Enregistrer un commentaire