My question is:
Is there a way to determine whether a parameter is a literal string or not?
template<class T>
bool IsLiteral(T arg)
{
// How to implement?
}
or
template<class T>
struct IsLiteral { enum { value = ??? }; };
So that we can write the following code:
char* p = "Hello";
assert(IsLiteral(p)); // fail.
assert(IsLiteral("Hello")); // never fail.
assert(IsLiteral<decltype("Hello")>::value); // never fail.