N4296 2.13.5 / 8
UTF-8 plain string literals and string literals are also indicated as narrow string literals. The narrow string literal is of type "array n const char" , where n is the size of the string, as defined below, and has a static storage duration (3.7).
But since the variable is initialized, as in your code, it is actually const char* , you can check it like this.
template<typename> struct TD; int main() { auto a = "Hello World"; TD<decltype(a)> _; }
An error will be compiled here in which you can see the actual type of the TD instance, something like this with clang
error: implicit instantiation of undefined template 'TD<const char *>'
N4296 7.1.6.4
If the placeholder is an automatic type specifier, the type being inferred is determined using the rules for deriving template arguments.
template<typename> struct TD; template<typename T> void f(T) { TD<T> _; } int main() { auto c = "Hello"; TD<decltype(c)> _; f("Hello"); }
Both instances of an object of type TD are of type TD<const char*> .
N4926 14.8.2.1
The output of the template argument is made by comparing each function with the type of the template template (call it P) with the type of the corresponding call argument (call it A), as described below.
If P is not a reference type:
If A is an array type, the pointer type created by the standard transformation using the pointer matrix (4.2) is used instead of A for the output type
source share