While exploring variadic templates, I found that recursive function could be with and without template but now my code is as below and I wondering why the add()
is not called and neither the compiler throws any warning.
//why this one is not called
void add(){
std::cout << "[]";
}
template <typename T>
void add(T x){
std::cout << x << "{}";
}
template <typename T, typename ...ARGS>
void add(T x, ARGS ...a){
std::cout << x << ":";
add(a...);
}
int main()
{
add(3.1, 3.4, "6.7", 4u, "7.54");
return 0;
}
Also when I comment add(T x)
, the add()
is called. I am confused.
Aucun commentaire:
Enregistrer un commentaire