foo(const char *)is selected above the template version for "hello". How to make the compiler choose a version of a template?
#include <iostream>
template <size_t N>
void foo(const char (&)[N])
{
std::cout << N << std::endl;
}
void foo(const char *)
{
std::cout << "char*" << std::endl;
}
int main()
{
foo("hello");
char a[] = "world";
foo(a);
}
Derek source
share