You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

platform.cpp 616 B

12345678910111213141516171819202122232425
  1. #include "megbrain/imperative/utils/platform.h"
  2. #ifdef __GNUG__
  3. #include <cxxabi.h>
  4. #include <cstdlib>
  5. #include <memory>
  6. #endif
  7. using namespace mgb;
  8. using namespace imperative;
  9. /*
  10. * demangle typeid, see
  11. * http://stackoverflow.com/questions/281818/unmangling-the-result-of-stdtype-infoname
  12. */
  13. std::string mgb::imperative::demangle(std::string mangled) {
  14. #ifdef __GNUG__
  15. int status = -1;
  16. std::unique_ptr<char, void (*)(void*)> res{
  17. abi::__cxa_demangle(mangled.c_str(), nullptr, nullptr, &status), std::free};
  18. return (status == 0) ? res.get() : mangled;
  19. #else
  20. return mangled;
  21. #endif
  22. }