From 48901cd1a43949c64fcfbdddc1e774147d8d74ad Mon Sep 17 00:00:00 2001 From: John Jones Date: Fri, 10 Aug 2018 14:40:47 -0500 Subject: [PATCH] correct templating of static variant --- include/fc/static_variant.hpp | 43 ++++++++++++++++++++++++++++++++++- 1 file changed, 42 insertions(+), 1 deletion(-) 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