From 5ecc254a91c2e3f50d75c31d287ef908d9f77dc8 Mon Sep 17 00:00:00 2001 From: Michele Caini Date: Thu, 15 Feb 2024 10:09:40 +0100 Subject: [PATCH] core: export more types as fwd decl - close #1114 --- src/entt/core/compressed_pair.hpp | 1 + src/entt/core/fwd.hpp | 14 ++++++++++++++ src/entt/core/hashed_string.hpp | 6 ------ src/entt/core/type_info.hpp | 12 ++++++------ 4 files changed, 21 insertions(+), 12 deletions(-) diff --git a/src/entt/core/compressed_pair.hpp b/src/entt/core/compressed_pair.hpp index 9b8d65c90..22431afde 100644 --- a/src/entt/core/compressed_pair.hpp +++ b/src/entt/core/compressed_pair.hpp @@ -5,6 +5,7 @@ #include #include #include +#include "fwd.hpp" #include "type_traits.hpp" namespace entt { diff --git a/src/entt/core/fwd.hpp b/src/entt/core/fwd.hpp index 472ed122d..ce7e20c9a 100644 --- a/src/entt/core/fwd.hpp +++ b/src/entt/core/fwd.hpp @@ -15,6 +15,20 @@ using id_type = ENTT_ID_TYPE; /*! @brief Alias declaration for the most common use case. */ using any = basic_any<>; +template +class compressed_pair; + +template +class basic_hashed_string; + +/*! @brief Aliases for common character types. */ +using hashed_string = basic_hashed_string; + +/*! @brief Aliases for common character types. */ +using hashed_wstring = basic_hashed_string; + +struct type_info; + } // namespace entt #endif diff --git a/src/entt/core/hashed_string.hpp b/src/entt/core/hashed_string.hpp index 0dad38a10..e15840d12 100644 --- a/src/entt/core/hashed_string.hpp +++ b/src/entt/core/hashed_string.hpp @@ -293,12 +293,6 @@ template return !(lhs < rhs); } -/*! @brief Aliases for common character types. */ -using hashed_string = basic_hashed_string; - -/*! @brief Aliases for common character types. */ -using hashed_wstring = basic_hashed_string; - inline namespace literals { /** diff --git a/src/entt/core/type_info.hpp b/src/entt/core/type_info.hpp index 564abb984..14ab896fc 100644 --- a/src/entt/core/type_info.hpp +++ b/src/entt/core/type_info.hpp @@ -246,6 +246,12 @@ private: * @return A reference to a properly initialized type info object. */ template +[[nodiscard]] const type_info &type_id(Type &&) noexcept { + return type_id>>(); +} + +/*! @copydoc type_id */ +template [[nodiscard]] const type_info &type_id() noexcept { if constexpr(std::is_same_v>>) { static type_info instance{std::in_place_type}; @@ -255,12 +261,6 @@ template } } -/*! @copydoc type_id */ -template -[[nodiscard]] const type_info &type_id(Type &&) noexcept { - return type_id>>(); -} - } // namespace entt #endif