I have a function check_str that is overloaded for const char* and const char(&)[N] types.
void check_str(const char*) {
std::cout << "string as pointer!!" << '\n';
}
template <size_t N>
void check_str(const char(&)[N]) {
std::cout << "string as array!!" << '\n';
}
Then, I declared arr_01 as const char[]:
const char arr_01[] = "Desmond";
When I call them:
check_str("Desmond");
check_str(arr_01);
The first call prints "string as pointer!!" while the second call still prints "string as pointer!!".
Well, if I use std::string or std::string_view, it will lose the point of classifying them.
Is there a way to call the overloaded function that has the argument type const char(&)[N] for arr_01 in order to print "string as array!!" without specifying the non-type template parameter?