Skip to content

Instantly share code, notes, and snippets.

@yangacer
Created August 11, 2012 15:05
Show Gist options
  • Save yangacer/3325136 to your computer and use it in GitHub Desktop.
Save yangacer/3325136 to your computer and use it in GitHub Desktop.
gcc demangling
#include <typeinfo>
#include <memory>
#ifdef __GNUC__
#include <cxxabi.h>
template<typename T>
struct getname
{
std::string operator()()
{
int status(-4);
std::shared_ptr<char> res(abi::__cxa_demangle(typeid(T).name(), 0, 0, &status));
return (res) ? res.get() : typeid(T).name();
}
};
#endif
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment