type_name.h 810 B

123456789101112131415161718192021222324252627282930
  1. #pragma once
  2. #include <util/generic/string.h>
  3. #include <util/string/subst.h>
  4. #include <typeindex>
  5. #include <typeinfo>
  6. // Consider using TypeName function family.
  7. TString CppDemangle(const TString& name);
  8. // TypeName function family return human readable type name.
  9. TString TypeName(const std::type_info& typeInfo);
  10. TString TypeName(const std::type_index& typeInfo);
  11. // Works for types known at compile-time
  12. // (thus, does not take any inheritance into account)
  13. template <class T>
  14. inline TString TypeName() {
  15. return TypeName(typeid(T));
  16. }
  17. // Works for dynamic type, including complex class hierarchies.
  18. // Also, distinguishes between T, T*, T const*, T volatile*, T const volatile*,
  19. // but not T and T const.
  20. template <class T>
  21. inline TString TypeName(const T& t) {
  22. return TypeName(typeid(t));
  23. }