@ -34,22 +34,21 @@ static std::string demangle_name(const char* mangled)
int _status ;
int _status ;
} ;
} ;
size_t len ;
int status = 0 ;
int status ;
char * demangled = abi : : __cxa_demangle ( mangled , nullptr , nullptr /* This never seems to be even close to accurate, it's always off by a long shot and idk why? */ , & status ) ;
char * demangled = abi : : __cxa_demangle ( mangled , nullptr , & len , & status ) ;
const auto c_str_to_string = [ len ] ( char * str )
auto c_str_to_string = [ ] ( char * str )
noexcept ( std : : is_nothrow_constructible_v < std : : string , const char * , size_t > )
noexcept ( std : : is_nothrow_constructible_v < std : : string , const char * , size_t > )
{
{
const auto _free = [ & ] ( ) { free ( static_cast < void * > ( str ) ) ; } ;
const auto _free = [ & ] ( ) { free ( static_cast < void * > ( str ) ) ; } ;
if constexpr ( std : : is_nothrow_constructible_v < std : : string , const char * , size_t > ) {
if constexpr ( std : : is_nothrow_constructible_v < std : : string , const char * , size_t > ) {
std : : string v { str , len };
std : : string v { str };
_free ( ) ;
_free ( ) ;
return v ;
return v ;
} else {
} else {
try {
try {
std : : string v { str , len };
std : : string v { str };
_free ( ) ;
_free ( ) ;
return v ;
return v ;
} catch ( . . . ) {
} catch ( . . . ) {
@ -67,7 +66,8 @@ static std::string demangle_name(const char* mangled)
inline static std : : string demangle_name ( const std : : string & mangled )
inline static std : : string demangle_name ( const std : : string & mangled )
{
{
return demangle_name ( mangled . c_str ( ) ) ;
const auto & tmp = mangled ;
return demangle_name ( tmp . c_str ( ) ) ;
}
}
static inline void s_puts ( const auto & string , FILE * to = nullptr )
static inline void s_puts ( const auto & string , FILE * to = nullptr )
@ -87,12 +87,14 @@ static void print_name(const std::type_info& type)
const char * name = type . name ( ) ;
const char * name = type . name ( ) ;
s_puts ( " type holds: " ) ;
s_puts ( " type holds: " ) ;
try {
try {
s_puts ( demangle_name ( name ) ) ;
const auto dm = demangle_name ( name ) ;
s_puts ( " \n " ) ;
s_puts ( " ` " ) ;
} catch ( demangle_failed & err ) {
s_puts ( dm ) ;
s_puts ( " <mangled> " ) ;
s_puts ( " ` \n " ) ;
} catch ( const demangle_failed & err ) {
s_puts ( " <mangled> ` " ) ;
s_puts ( name ) ;
s_puts ( name ) ;
s_puts ( " \n " ) ;
s_puts ( " ` \n " ) ;
s_puts ( " Failed to demangle name: " , stderr ) ;
s_puts ( " Failed to demangle name: " , stderr ) ;
s_puts ( err . what ( ) , stderr ) ;
s_puts ( err . what ( ) , stderr ) ;