5 #ifndef GKO_PUBLIC_CORE_BASE_NAME_DEMANGLING_HPP_
6 #define GKO_PUBLIC_CORE_BASE_NAME_DEMANGLING_HPP_
9 #include <ginkgo/config.hpp>
12 #ifdef GKO_HAVE_CXXABI_H
14 #endif // GKO_HAVE_CXXABI_H
28 namespace name_demangling {
31 inline std::string get_type_name(
const std::type_info& tinfo)
33 #ifdef GKO_HAVE_CXXABI_H
35 const std::string name(
36 std::unique_ptr<
char[],
void (*)(
void*)>(
37 abi::__cxa_demangle(tinfo.name(),
nullptr,
nullptr, &status),
43 #endif // GKO_HAVE_CXXABI_H
44 return std::string(tinfo.name());
59 return get_type_name(
typeid(T));
74 return get_type_name(
typeid(t));
82 std::string get_enclosing_scope(
const T&)
84 auto name = get_type_name(
typeid(T));
85 auto found = name.rfind(
':');
86 if (found == std::string::npos) {
89 return name.substr(0, found - 1);
109 #define GKO_FUNCTION_NAME gko::name_demangling::get_enclosing_scope([] {})
116 #endif // GKO_PUBLIC_CORE_BASE_NAME_DEMANGLING_HPP_