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

前端 未结 2 494
無奈伤痛
無奈伤痛 2020-12-16 18:38

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 str

2条回答
  •  夕颜
    夕颜 (楼主)
    2020-12-16 19:06

    You have to remove the reference first, since the type deduced by decltype is const char (&)[N], not just const char [N]:

    std::cout << std::boolalpha << std::is_array<
        typename std::remove_reference::type
    >::value << '\n'; // true
    

提交回复
热议问题