3#ifndef TTG_DEMANGLE_H_INCLUDED
4#define TTG_DEMANGLE_H_INCLUDED
10#define HAVE_CXA_DEMANGLE
11#ifdef HAVE_CXA_DEMANGLE
16 static std::string demangled_type_name(T *x =
nullptr) {
17 const char *name =
nullptr;
18 if constexpr (std::is_void_v<T>)
21 name = (x !=
nullptr) ?
typeid(*x).name() :
23 static size_t buf_size = 1024;
24 static std::unique_ptr<char,
decltype(std::free) *> buf{
reinterpret_cast<char *
>(malloc(
sizeof(
char) * buf_size)),
27 char *res = abi::__cxa_demangle(name, buf.get(), &buf_size, &status);
28 if (status != 0 || res ==
nullptr) {
31 if (res != buf.get()) {
33 buf = std::unique_ptr<char,
decltype(std::free) *>{res, std::free};
40std::string demangled_type_name(T* x =
nullptr) {
41 const char* name = (x !=
nullptr) ?
typeid(*x).name() :
43 return std::string(name);
top-level TTG namespace contains runtime-neutral functionality