From 4e993f2d4dfaecbddd0d7f2641b1dfa0f0ba0b1c Mon Sep 17 00:00:00 2001 From: Danny Robson Date: Thu, 9 Feb 2017 16:48:42 +1100 Subject: [PATCH] introspection: add type_char trait --- introspection.hpp | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/introspection.hpp b/introspection.hpp index e1287468..b0de712c 100644 --- a/introspection.hpp +++ b/introspection.hpp @@ -78,6 +78,26 @@ namespace util { { return type_name_v; } + /////////////////////////////////////////////////////////////////////////// + template + struct type_char; + + template <> struct type_char { static constexpr char value = 'f'; }; + template <> struct type_char { static constexpr char value = 'd'; }; + + template <> struct type_char< int8_t> { static constexpr char value = 'i'; }; + template <> struct type_char< int16_t> { static constexpr char value = 'i'; }; + template <> struct type_char< int32_t> { static constexpr char value = 'i'; }; + template <> struct type_char< int64_t> { static constexpr char value = 'i'; }; + + template <> struct type_char< uint8_t> { static constexpr char value = 'u'; }; + template <> struct type_char { static constexpr char value = 'u'; }; + template <> struct type_char { static constexpr char value = 'u'; }; + template <> struct type_char { static constexpr char value = 'u'; }; + + template + constexpr auto type_char_v = type_char::value; + /////////////////////////////////////////////////////////////////////////// /// Lists valid values of an enumeration ///