1
0
Эх сурвалжийг харах

type_info: full_type_name vs stripped_type_name

skypjack 10 сар өмнө
parent
commit
57d604bcb2

+ 10 - 5
src/entt/core/type_info.hpp

@@ -22,17 +22,22 @@ struct ENTT_API type_index final {
 };
 
 template<typename Type>
-[[nodiscard]] constexpr auto stripped_type_name() noexcept {
+[[nodiscard]] constexpr auto full_type_name() noexcept {
 #if defined ENTT_PRETTY_FUNCTION
-    const std::string_view pretty_function{static_cast<const char *>(ENTT_PRETTY_FUNCTION)};
-    auto first = pretty_function.find_first_not_of(' ', pretty_function.find_first_of(ENTT_PRETTY_FUNCTION_PREFIX) + 1);
-    auto value = pretty_function.substr(first, pretty_function.find_last_of(ENTT_PRETTY_FUNCTION_SUFFIX) - first);
-    return value;
+    return std::string_view{static_cast<const char *>(ENTT_PRETTY_FUNCTION)};
 #else
     return std::string_view{};
 #endif
 }
 
+template<typename Type>
+[[nodiscard]] constexpr auto stripped_type_name() noexcept {
+    const std::string_view full_name = full_type_name<Type>();
+    auto first = full_name.find_first_not_of(' ', full_name.find_first_of(ENTT_PRETTY_FUNCTION_PREFIX) + 1);
+    auto value = full_name.substr(first, full_name.find_last_of(ENTT_PRETTY_FUNCTION_SUFFIX) - first);
+    return value;
+}
+
 template<typename Type, auto = stripped_type_name<Type>().find_first_of('.')>
 [[nodiscard]] constexpr std::string_view type_name(int) noexcept {
     constexpr auto value = stripped_type_name<Type>();