I have this function that is a a variadic template function:
template<uint C>
double foo(){
double cpt = 1;
for(uint i=0; i<10; i++){
cpt += i*C;
}
return cpt;
}
template<uint C1, uint C2, uint... CCs>
double foo(){
double cpt = 1;
for(uint i=0; i<10; i++){
cpt += i*C1;
}
return cpt + foo<C2, CCs...>();
}
And it works perfectly as expected but I think it is not the correct way to do what I want to do. I tried to write something like that:
double foo(){
return 0;
}
template<uint C1, uint... CCs>
double foo(){
double cpt = 1;
for(uint i=0; i<10; i++){
cpt += i*C1;
}
return cpt + f<CCs...>();
}
But I have the error no matching function for call foo() note: couldn't deduce template parameter C1. I also tried with a template <typename T> on top of the first foo function but I have the same error.
Does someone know why ? I am using g++ 5.4 with -std=c++11 and -O3 flags.
Aucun commentaire:
Enregistrer un commentaire