Fix type_name for abstract classes. Fixes #172.

This commit is contained in:
Peter Dimov
2024-04-24 21:46:32 +03:00
parent d03e58b77e
commit 965508d9e1
2 changed files with 20 additions and 2 deletions

View File

@@ -103,7 +103,8 @@ inline std::string fix_typeid_name( char const* n )
}
// class types can be incomplete
template<class T> std::string typeid_name_impl( int T::* )
// but also abstract (T[1] doesn't form)
template<class T> std::string typeid_name_impl( int T::*, T(*)[1] )
{
std::string r = fix_typeid_name( typeid(T[1]).name() );
return r.substr( 0, r.size() - 4 ); // remove ' [1]' suffix
@@ -116,7 +117,7 @@ template<class T> std::string typeid_name_impl( ... )
template<class T> std::string typeid_name()
{
return typeid_name_impl<T>( 0 );
return typeid_name_impl<T>( 0, 0 );
}
// template names