introspection: use pointers over arrays for type_name

It's too hard to diagnose undefined symbol issues under clang so we use
pointers for the time being.
This commit is contained in:
Danny Robson 2016-11-17 18:33:16 +11:00
parent 67f2aee701
commit a10c091114
2 changed files with 32 additions and 30 deletions

View File

@ -18,21 +18,21 @@
///////////////////////////////////////////////////////////////////////////////
constexpr char util::type_name<bool>::value[];
constexpr const char* ::util::type_name<bool>::value;
constexpr char util::type_name< int8_t>::value[];
constexpr char util::type_name< int16_t>::value[];
constexpr char util::type_name< int32_t>::value[];
constexpr char util::type_name< int64_t>::value[];
constexpr const char* ::util::type_name< int8_t>::value;
constexpr const char* ::util::type_name< int16_t>::value;
constexpr const char* ::util::type_name< int32_t>::value;
constexpr const char* ::util::type_name< int64_t>::value;
constexpr char util::type_name< uint8_t>::value[];
constexpr char util::type_name<uint16_t>::value[];
constexpr char util::type_name<uint32_t>::value[];
constexpr char util::type_name<uint64_t>::value[];
constexpr const char* ::util::type_name< uint8_t>::value;
constexpr const char* ::util::type_name<uint16_t>::value;
constexpr const char* ::util::type_name<uint32_t>::value;
constexpr const char* ::util::type_name<uint64_t>::value;
constexpr char util::type_name<float>::value[];
constexpr char util::type_name<double>::value[];
constexpr const char* ::util::type_name<float>::value;
constexpr const char* ::util::type_name<double>::value;
constexpr char util::type_name<std::string>::value[];
constexpr char util::type_name<char*>::value[];
constexpr char util::type_name<const char*>::value[];
constexpr const char* ::util::type_name<std::string>::value;
constexpr const char* ::util::type_name<char*>::value;
constexpr const char* ::util::type_name<const char*>::value;

View File

@ -26,30 +26,32 @@
#include <tuple>
namespace util {
// XXX: we should be using a const char[] here, but clang-3.9 will not
// instantiate array values within template specialisations.
template <typename T>
struct type_name;
template <> struct type_name<bool> { static constexpr const char value[] = "bool"; };
template <> struct type_name<bool> { static constexpr const char *value = "bool"; };
template <> struct type_name<char> { static constexpr const char value[] = "char"; };
template <> struct type_name<void*> { static constexpr const char value[] = "void*"; };
template <> struct type_name<char> { static constexpr const char *value = "char"; };
template <> struct type_name<void*> { static constexpr const char *value = "void*"; };
template <> struct type_name< int8_t> { static constexpr const char value[] = "int8"; };
template <> struct type_name< int16_t> { static constexpr const char value[] = "int16"; };
template <> struct type_name< int32_t> { static constexpr const char value[] = "int32"; };
template <> struct type_name< int64_t> { static constexpr const char value[] = "int64"; };
template <> struct type_name< int8_t> { static constexpr const char *value = "int8"; };
template <> struct type_name< int16_t> { static constexpr const char *value = "int16"; };
template <> struct type_name< int32_t> { static constexpr const char *value = "int32"; };
template <> struct type_name< int64_t> { static constexpr const char *value = "int64"; };
template <> struct type_name< uint8_t> { static constexpr const char value[] = "uint8"; };
template <> struct type_name<uint16_t> { static constexpr const char value[] = "uint16"; };
template <> struct type_name<uint32_t> { static constexpr const char value[] = "uint32"; };
template <> struct type_name<uint64_t> { static constexpr const char value[] = "uint64"; };
template <> struct type_name< uint8_t> { static constexpr const char *value = "uint8"; };
template <> struct type_name<uint16_t> { static constexpr const char *value = "uint16"; };
template <> struct type_name<uint32_t> { static constexpr const char *value = "uint32"; };
template <> struct type_name<uint64_t> { static constexpr const char *value = "uint64"; };
template <> struct type_name<float > { static constexpr const char value[] = "float32"; };
template <> struct type_name<double > { static constexpr const char value[] = "float64"; };
template <> struct type_name<float > { static constexpr const char *value = "float32"; };
template <> struct type_name<double > { static constexpr const char *value = "float64"; };
template <> struct type_name<std::string> { static constexpr const char value[] = "string"; };
template <> struct type_name<char*> { static constexpr const char value[] = "cstring"; };
template <> struct type_name<const char*> { static constexpr const char value[] = "cstring"; };
template <> struct type_name<std::string> { static constexpr const char *value = "string"; };
template <> struct type_name<char*> { static constexpr const char *value = "cstring"; };
template <> struct type_name<const char*> { static constexpr const char *value = "cstring"; };
template <typename T>
constexpr