mirror of
https://github.com/mpusz/mp-units.git
synced 2025-06-25 01:01:33 +02:00
fix: text stripping in type_name
fixed
This commit is contained in:
@ -6,6 +6,7 @@
|
||||
#pragma once
|
||||
|
||||
#ifndef MP_UNITS_IN_MODULE_INTERFACE
|
||||
#include <mp-units/ext/contracts.h>
|
||||
#ifdef MP_UNITS_IMPORT_STD
|
||||
import std;
|
||||
#else
|
||||
@ -22,17 +23,19 @@ template<typename T>
|
||||
std::string_view name, prefix, suffix;
|
||||
#ifdef __clang__
|
||||
name = __PRETTY_FUNCTION__;
|
||||
prefix = "auto type_name() [T = ";
|
||||
prefix = "std::string_view mp_units::detail::type_name() [T = ";
|
||||
suffix = "]";
|
||||
#elif defined(__GNUC__)
|
||||
name = __PRETTY_FUNCTION__;
|
||||
prefix = "constexpr auto type_name() [with T = ";
|
||||
prefix = "consteval std::string_view mp_units::detail::type_name() [with T = ";
|
||||
suffix = "]";
|
||||
#elif defined(_MSC_VER)
|
||||
name = __FUNCSIG__;
|
||||
prefix = "auto __cdecl type_name<";
|
||||
prefix = "class std::basic_string_view<char,struct std::char_traits<char> > __cdecl mp_units::detail::type_name<";
|
||||
suffix = ">(void)";
|
||||
#endif
|
||||
MP_UNITS_ASSERT_DEBUG(name.starts_with(prefix));
|
||||
MP_UNITS_ASSERT_DEBUG(name.ends_with(suffix));
|
||||
name.remove_prefix(prefix.size());
|
||||
name.remove_suffix(suffix.size());
|
||||
return name;
|
||||
|
Reference in New Issue
Block a user