I want to overload a function that works for string literals and std::string , but will generate a compile-time error for const char* parameters. The following code does almost what I want:
#include <iostream>
I am not happy that it compiles for a char array variable, but I think there is no way around this if I want to accept string literals (if there is, tell me please)
However, I would like to avoid std::string overload accepting const char * const variables. Unfortunately, I cannot just declare a remote overload that accepts the const char * const& parameter, because this will also correspond to a string literal.
Any idea how I can make foo(c_ptr) create a compile-time error without affecting other overloads?
c ++ string overloading
Mikemb
source share