Skip to content

Instantly share code, notes, and snippets.

@fowlmouth
Created January 24, 2017 19:55
Show Gist options
  • Save fowlmouth/c55e86e039537fd6db9e28f3e9e7f15d to your computer and use it in GitHub Desktop.
Save fowlmouth/c55e86e039537fd6db9e28f3e9e7f15d to your computer and use it in GitHub Desktop.
#include <typeinfo>
#include <cxxabi.h>
#include <string>
template<typename T>
std::string demangled_name()
{
int status;
const char* name = typeid(T).name();
char* res = abi::__cxa_demangle(name, nullptr, nullptr, &status);
const char* demangled = (status == 0) ? res : name;
std::string retval(demangled);
std::free(res);
return retval;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment