foo(const char *)
is chosen over template version for "hello"
. How to make the compiler choose template version instead?
#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);
}