Let\'s say I have these two overloads:
void Log(const wchar_t* message)
{
// Do something
}
void Log(const std::wstring& message)
{
// Do someth
Adding this alternative for future reference. It comes from the SO question Is it possible to overload a function that can tell a fixed array from a pointer?
#include
#include
template
std::enable_if_t::value>
foo(T)
{
std::cout << "pointer\n";
}
template
void foo(T(&)[sz])
{
std::cout << "array\n";
}
int main()
{
char const* c = nullptr;
char d[] = "qwerty";
foo(c);
foo(d);
foo("hello");
}
The above snippet compiles and runs fine on http://webcompiler.cloudapp.net/