考虑以下计划:
#include <iostream>
#include <type_traits>
int main(int argc, char* argv[])
{
std::cout << std::is_same<decltype("hello"), char*>::value << std::endl;
std::cout << std::is_same<decltype("hello"), const char*>::value << std::endl;
std::cout << std::is_same<decltype("hello"), char[5]>::value << std::endl;
std::cout << std::is_same<decltype("hello"), const char[5]>::value << std::endl;
std::cout << std::is_same<decltype("hello"), char[6]>::value << std::endl;
std::cout << std::is_same<decltype("hello"), const char[6]>::value << std::endl;
std::cout << std::is_same<decltype("hello"), char[]>::value << std::endl;
std::cout << std::is_same<decltype("hello"), const char[]>::value << std::endl;
return 0;
}
它只返回零,而我希望"hello"
为const char[6]
。 "hello"
的类型是什么?