Improve C++ Name Demangling
With the demangling right now, more complex types (such as a string!) are hardly readable:
Mismatch of argument type "int" to provided type "std::__cxx11::basic_string
<char, std::char_traits<char>, std::allocator<char> >"
or, even more beautifully, for a vector of time points:
Mismatch of argument type "int" to provided type "std::vector<std::chrono::
time_point<std::chrono::_V2::system_clock, std::chrono::duration<long, std::
ratio<1l, 1000000000l> > >, std::allocator<std::chrono::time_point<std::
chrono::_V2::system_clock, std::chrono::duration<long, std::ratio<1l,
1000000000l> > > > >"
we should investigate if there is a better demangling possibility. For compile-time names we can use source_location
, e.g. as
struct dummy_type {};
template <typename T> auto embed_type() {
return std::string_view {std::source_location::current().function_name()};
}
template <typename T> inline std::string_view demangle(const T& = {}) {
auto dummy_sig = embed_type<dummy_type>();
auto start = dummy_sig.find("dummy_type");
auto embed_sig = embed_type<T>();
auto type_length = embed_sig.size() - dummy_sig.size() + 10;
return embed_sig.substr(start, type_length);
}
which works beautifully - but not for run-time type_info
.