dimanche 17 mai 2015

Why does decltype on a string literal not yield an array type?

The standard defines a string literal's type, in §2.13.5/8, as:

Ordinary string literals and UTF-8 string literals are also referred to as narrow string literals. A narrow string literal has type “array of n const char”, where n is the size of the string as defined below, and has static storage duration (3.7).

Therefore, for example, "sss" should have a type char const[4] (unless I'm reading it incorrectly).

But this simple snippet:

std::cout << std::boolalpha << std::is_pointer<decltype("sss")>::value << '\n';
std::cout << std::boolalpha << std::is_array<decltype("sss")>::value;

gives:

false
false

What am I missing?

Aucun commentaire:

Enregistrer un commentaire