hot chocolate

v1
Brett 2023-12-07 16:03:38 -05:00
parent da891be991
commit 8defbaf70d
1 changed files with 17 additions and 11 deletions

View File

@ -26,21 +26,27 @@
#include <blt/compatibility.h> #include <blt/compatibility.h>
#include <string> #include <string>
static BLT_CPP20_CONSTEXPR inline std::string demangle(const std::string& str) namespace blt
{ {
int status; static BLT_CPP20_CONSTEXPR inline std::string demangle(const std::string& str)
// only defined for GNU C++11? {
char *demangled_name = abi::__cxa_demangle(str.c_str(), nullptr, nullptr, &status); int status;
if (demangled_name == nullptr) // only defined for GNU C++11?
return str; char* demangled_name = abi::__cxa_demangle(str.c_str(), nullptr, nullptr, &status);
std::string ret_name = demangled_name; if (demangled_name == nullptr)
std::free(demangled_name); return str;
return ret_name; std::string ret_name = demangled_name;
std::free(demangled_name);
return ret_name;
}
} }
#else #else
static BLT_CPP20_CONSTEXPR inline std::string demangle(const std::string& str) namespace blt
{ {
return str; static BLT_CPP20_CONSTEXPR inline std::string demangle(const std::string& str)
{
return str;
}
} }
#endif #endif