fork download
  1. #include <iostream>
  2. #include <typeinfo>
  3. using namespace std;
  4.  
  5. #include <cstdlib>
  6. #include <memory>
  7. #include <cxxabi.h>
  8.  
  9. std::string demangle(const char* name) {
  10.  
  11. int status = -4; // some arbitrary value to eliminate the compiler warning
  12.  
  13. // enable c++11 by passing the flag -std=c++11 to g++
  14. std::unique_ptr<char, void(*)(void*)> res {
  15. abi::__cxa_demangle(name, NULL, NULL, &status),
  16. std::free
  17. };
  18.  
  19. return (status==0) ? res.get() : name ;
  20. }
  21.  
  22. int main() {
  23. cout << demangle(typeid(decltype("Hello, world!")).name()) << endl;
  24. return 0;
  25. }
Success #stdin #stdout 0s 15240KB
stdin
Standard input is empty
stdout
char [14]