Created
July 8, 2015 23:55
-
-
Save bwoods/bbc6bd26b73fa37e94ac to your computer and use it in GitHub Desktop.
demangle C++ TypeID names (std::unique_ptr version)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <cxxabi.h> // gcc and clang… | |
#include <stdlib.h> | |
auto demangle(std::string&& name) -> std::unique_ptr<char, void(*)(char *)> | |
{ | |
int status = 0; | |
return { abi::__cxa_demangle(name.c_str(), nullptr, nullptr, &status), [] (char * p) { ::free(p); } }; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <memory> | |
auto demangle(std::string&& name) -> std::unique_ptr<char, void(*)(char *)>; | |
template <typename T> | |
auto declname() { return demangle(typeid(std::declval<T>()).name()); } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment