diff --git a/src/entt/core/type_traits.hpp b/src/entt/core/type_traits.hpp index 9c1fdbe37..e483747e6 100644 --- a/src/entt/core/type_traits.hpp +++ b/src/entt/core/type_traits.hpp @@ -43,14 +43,55 @@ template struct shared_traits; +/** + * @brief Specialization used to get rid of constness. + * @tparam Type Shared type. + */ +template +struct shared_traits + : shared_traits +{}; + + +/** + * @brief Provides the member constant `value` to true if a given type is + * shared. In all other cases, `value` is false. + */ +template> +struct is_shared: std::false_type {}; + + +/** + * @brief Provides the member constant `value` to true if a given type is + * shared. In all other cases, `value` is false. + * @tparam Type Potentially shared type. + */ +template +struct is_shared>::type>>: std::true_type {}; + + +/** + * @brief Helper variable template. + * + * True if a given type is shared, false otherwise. + * + * @tparam Type Potentially shared type. + */ +template +constexpr auto is_shared_v = is_shared::value; + + +} + + /** * @brief Makes an already existing type a shared type. * @param type Type to make shareable. */ #define ENTT_SHARED_TYPE(type)\ template<>\ - struct shared_traits\ - : std::integral_constant\ + struct entt::shared_traits\ + : std::integral_constant\ {} @@ -74,35 +115,4 @@ struct shared_traits; class clazz -/** - * @brief Provides the member constant `value` to true if a given type is - * shared. In all other cases, `value` is false. - */ -template -struct is_shared: std::false_type {}; - - -/** - * @brief Provides the member constant `value` to true if a given type is - * shared. In all other cases, `value` is false. - * @tparam Type Potentially shared type. - */ -template -struct is_shared>: std::true_type {}; - - -/** - * @brief Helper variable template. - * - * True if a given type is shared, false otherwise. - * - * @tparam Type Potentially shared type. - */ -template -constexpr auto is_shared_v = is_shared::value; - - -} - - #endif // ENTT_CORE_TYPE_TRAITS_HPP diff --git a/test/lib/a_module.cpp b/test/lib/a_module.cpp index 7f3d51c6b..ed65e160e 100644 --- a/test/lib/a_module.cpp +++ b/test/lib/a_module.cpp @@ -10,6 +10,11 @@ #endif #endif +ENTT_SHARED_TYPE(int); +ENTT_SHARED_TYPE(char); +ENTT_SHARED_TYPE(double); +ENTT_SHARED_TYPE(float); + LIB_EXPORT typename entt::registry<>::component_type a_module_int_type() { entt::registry<> registry; diff --git a/test/lib/another_module.cpp b/test/lib/another_module.cpp index d32a1fa74..451539b28 100644 --- a/test/lib/another_module.cpp +++ b/test/lib/another_module.cpp @@ -10,6 +10,11 @@ #endif #endif +ENTT_SHARED_TYPE(int); +ENTT_SHARED_TYPE(char); +ENTT_SHARED_TYPE(double); +ENTT_SHARED_TYPE(float); + LIB_EXPORT typename entt::registry<>::component_type another_module_int_type() { entt::registry<> registry; diff --git a/test/lib/lib.cpp b/test/lib/lib.cpp index 9905a16f2..540bbe82e 100644 --- a/test/lib/lib.cpp +++ b/test/lib/lib.cpp @@ -6,6 +6,9 @@ extern typename entt::registry<>::component_type a_module_char_type(); extern typename entt::registry<>::component_type another_module_int_type(); extern typename entt::registry<>::component_type another_module_char_type(); +ENTT_SHARED_TYPE(int); +ENTT_SHARED_TYPE(char); + TEST(Lib, Shared) { entt::registry<> registry;