Add support for incomplete classes to type_name<>. Refs #145.

This commit is contained in:
Peter Dimov 2023-05-21 05:52:33 +03:00
parent 97606908b7
commit 36fa78f53c

View File

@ -102,11 +102,23 @@ inline std::string fix_typeid_name( char const* n )
return r;
}
template<class T> std::string typeid_name()
// class types can be incomplete
template<class T> 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<class T> std::string typeid_name_impl( ... )
{
return fix_typeid_name( typeid(T).name() );
}
template<class T> std::string typeid_name()
{
return typeid_name_impl<T>( 0 );
}
// template names
template<class T> std::string class_template_name()