Commit 06f91cdd authored by Martin Marinov's avatar Martin Marinov

Remove struct and class from the Boost-generated type_name string

parent cfcdeaf6
......@@ -24,13 +24,26 @@ namespace Cpp
{
#ifdef JOURNAL_USE_BOOST
template <size_t n>
void erase_start_substring(String& _str, const char (&_substr)[n])
{
if (_str.rfind(_substr, 0) == 0) // is _substr at the start?
_str.erase(0, n - 1);
}
void filter_type_name(String& _type_name)
{
erase_start_substring(_type_name, "struct ");
erase_start_substring(_type_name, "class ");
#ifdef _MSC_VER
// on MSVC, pointer types contain __ptr64 which is MSVC only, so filter it out
const char PTR64_STR[] = " __ptr64";
const auto pos = _type_name.find(PTR64_STR);
if (pos != String::npos)
_type_name.erase(pos, sizeof(PTR64_STR) - 1);
#endif // _MSC_VER
}
#endif
......
......@@ -34,10 +34,7 @@ void filter_type_name(String& _type_name);
template <class T> String type_name()
{
auto str = boost::core::demangled_name(BOOST_CORE_TYPEID(T));
#ifdef _MSC_VER
// on MSVC, pointer types contain __ptr64 which is MSVC only, so filter it out
filter_type_name(str);
#endif // _MSC_VER
filter_type_name(str); // apply some filtering to fix & simplify type names
return str;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment