Advertisement
zhangsongcui

getReadableTypeinfo

Sep 23rd, 2011
211
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.49 KB | None | 0 0
  1. #include <iostream>
  2. #include <typeinfo>
  3. #include <cxxabi.h>
  4. #include <cstdlib>
  5. #include <string>
  6.  
  7. std::string getReadableTypeinfo(const char* info)
  8. {
  9.     int status;
  10.     char* s=abi::__cxa_demangle(info, /*nullptr*/NULL, /*nullptr*/NULL, &status);
  11.     if (status != 0)
  12.         return "Invalid argument";
  13.     std::string result = s;
  14.     free(s);
  15.     return result;
  16. }
  17.  
  18. int main()
  19. {
  20.     using namespace std;
  21.     cout << getReadableTypeinfo(typeid(getReadableTypeinfo).name()) << endl;
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement