diff --git a/include/fc/reflect/typename.hpp b/include/fc/reflect/typename.hpp index 5cd55c9..55695c2 100644 --- a/include/fc/reflect/typename.hpp +++ b/include/fc/reflect/typename.hpp @@ -2,10 +2,12 @@ #include #include +#include #include #include #include +#include #include #include @@ -69,10 +71,36 @@ namespace fc { return n.c_str(); } }; + template struct get_typename< std::set > + { + static const char* name() + { + static std::string n = std::string("std::set<") + std::string(get_typename::name()) + std::string(">"); + return n.c_str(); + } + }; + template struct get_typename< std::pair > + { + static const char* name() + { + static std::string n = std::string("std::pair<") + get_typename::name() + "," + get_typename::name() + ">"; + return n.c_str(); + } + }; + template struct get_typename< fc::smart_ref > + { + static const char* name() + { + static std::string n = std::string("fc::smart_ref<") + get_typename::name() + std::string(">"); + return n.c_str(); + } + }; struct signed_int; struct unsigned_int; + struct variant_object; template<> struct get_typename { static const char* name() { return "signed_int"; } }; template<> struct get_typename { static const char* name() { return "unsigned_int"; } }; + template<> struct get_typename { static const char* name() { return "fc::variant_object"; } }; } diff --git a/include/fc/static_variant.hpp b/include/fc/static_variant.hpp index 02fb5dc..88efeda 100644 --- a/include/fc/static_variant.hpp +++ b/include/fc/static_variant.hpp @@ -382,5 +382,46 @@ public: s.visit( to_static_variant(ar[1], max_depth - 1) ); } - template struct get_typename { static const char* name() { return typeid(static_variant).name(); } }; + template< typename... T > struct get_comma_separated_typenames; + + template<> + struct get_comma_separated_typenames<> + { + static const char* names() { return ""; } + }; + + template< typename T > + struct get_comma_separated_typenames + { + static const char* names() + { + static const std::string n = get_typename::name(); + return n.c_str(); + } + }; + + template< typename T, typename... Ts > + struct get_comma_separated_typenames + { + static const char* names() + { + static const std::string n = + std::string( get_typename::name() )+","+ + std::string( get_comma_separated_typenames< Ts... >::names() ); + return n.c_str(); + } + }; + + template< typename... T > + struct get_typename< static_variant< T... > > + { + static const char* name() + { + static const std::string n = std::string( "fc::static_variant<" ) + + get_comma_separated_typenames::names() + + ">"; + return n.c_str(); + } + }; + } // namespace fc