diff --git a/include/boost/core/type_name.hpp b/include/boost/core/type_name.hpp index 312373f..773b5f6 100644 --- a/include/boost/core/type_name.hpp +++ b/include/boost/core/type_name.hpp @@ -102,11 +102,23 @@ inline std::string fix_typeid_name( char const* n ) return r; } -template std::string typeid_name() +// class types can be incomplete +template std::string typeid_name_impl( int T::* ) +{ + std::string r = fix_typeid_name( typeid(T[1]).name() ); + return r.substr( 0, r.size() - 4 ); // remove ' [1]' suffix +} + +template std::string typeid_name_impl( ... ) { return fix_typeid_name( typeid(T).name() ); } +template std::string typeid_name() +{ + return typeid_name_impl( 0 ); +} + // template names template std::string class_template_name()