2 #ifndef TTG_DEMANGLE_H_INCLUDED
3 #define TTG_DEMANGLE_H_INCLUDED
9 #define HAVE_CXA_DEMANGLE
10 #ifdef HAVE_CXA_DEMANGLE
15 static std::string demangled_type_name(T *x =
nullptr) {
16 const char *name =
nullptr;
17 if constexpr (std::is_void_v<T>)
20 name = (x !=
nullptr) ?
typeid(*x).name() :
22 static size_t buf_size = 1024;
23 static std::unique_ptr<char, decltype(std::free) *> buf{
reinterpret_cast<char *
>(malloc(
sizeof(
char) * buf_size)),
26 char *res = abi::__cxa_demangle(name, buf.get(), &buf_size, &status);
27 if (status != 0 || res ==
nullptr) {
30 if (res != buf.get()) {
32 buf = std::unique_ptr<char, decltype(std::free) *>{res, std::free};
39 std::string demangled_type_name(T* x =
nullptr) {
40 const char* name = (x !=
nullptr) ?
typeid(*x).name() :
42 return std::string(name);
top-level TTG namespace contains runtime-neutral functionality