This is related to my earlier post. I'd like to know why one attempted solution didn't work.
template <typename... T> /* A */
size_t num_args ();
template <>
size_t num_args <> ()
{
return 0;
}
template <typename H, typename... T> /* B */
size_t num_args ()
{
return 1 + num_args <T...> ();
}
If I try to call, say, num_args<int,float>()
then the error is that the function call is ambiguous:
- A with T={int,float}
- B with H=int, T={float}
I don't understand how this is ambiguous -- A is a declaration and B is a definition of the function declared by A. Right?
I'm trying to make this example work and the responses to my earlier question seem to claim that it can never work.
If that's the case, what's the point of variadic free functions? What can they do?
See Question&Answers more detail:os