I'm making a C++ library which relies heavily on RTTI (customizable bridge to another language) and is very confused about string literal type.
This is a simple test I made to show the problem:
std::cout << typeid(const char*).name() << std::endl; // PKc
std::cout << std::any("").type().name() << std::endl; // PKc
std::cout << typeid("").name() << std::endl; // A1_c
For me it looks like the first two print the type for const char*
, but the last one is an array.
Why do results for std::any("").type()
and typeid("")
differ? Is there a way to get the first behavior, i.e. make results for string literals consistent (I use type identification to call different type handlers)?
P.S.: tests are done using Clang version 8.0.0-3 (tags/RELEASE_800/final) on Ubuntu 19.04.