vendredi 25 novembre 2016

variadic form is ambiguous with the nonvariadic form for a single argument

why in the following code compiler doesn't complain because of ambiguity?

template <typename T>
void print (const T& arg)
{
std::cout << arg << std::endl;
}
template <typename T, typename... Types>
void print (const T& firstArg, const Types&... args)
{
std::cout << firstArg << std::endl;    // print first argument
print(args...);                       // call print() for remaining arguments
}

Aucun commentaire:

Enregistrer un commentaire