|
|
@@ -44,41 +44,20 @@ struct shared_traits;
|
|
|
|
|
|
|
|
|
/**
|
|
|
- * @brief Makes an already existing type a shared type.
|
|
|
- * @param type Type to make shareable.
|
|
|
- */
|
|
|
-#define ENTT_SHARED_TYPE(type)\
|
|
|
- template<>\
|
|
|
- struct shared_traits<type>\
|
|
|
- : std::integral_constant<typename hashed_string::hash_type, hashed_string::to_value(#type)>\
|
|
|
- {}
|
|
|
-
|
|
|
-
|
|
|
-/**
|
|
|
- * @brief Defines a type as shareable (to use for structs).
|
|
|
- * @param clazz Name of the type to make shareable.
|
|
|
- */
|
|
|
-#define ENTT_SHARED_STRUCT(clazz)\
|
|
|
- struct clazz;\
|
|
|
- ENTT_SHARED_TYPE(clazz)\
|
|
|
- struct clazz
|
|
|
-
|
|
|
-
|
|
|
-/**
|
|
|
- * @brief Defines a type as shareable (to use for classes).
|
|
|
- * @param clazz Name of the type to make shareable.
|
|
|
+ * @brief Specialization used to get rid of constness.
|
|
|
+ * @tparam Type Shared type.
|
|
|
*/
|
|
|
-#define ENTT_SHARED_CLASS(clazz)\
|
|
|
- class clazz;\
|
|
|
- ENTT_SHARED_TYPE(clazz)\
|
|
|
- class clazz
|
|
|
+template<typename Type>
|
|
|
+struct shared_traits<const Type>
|
|
|
+ : shared_traits<Type>
|
|
|
+{};
|
|
|
|
|
|
|
|
|
/**
|
|
|
* @brief Provides the member constant `value` to true if a given type is
|
|
|
* shared. In all other cases, `value` is false.
|
|
|
*/
|
|
|
-template<typename>
|
|
|
+template<typename, typename = std::void_t<>>
|
|
|
struct is_shared: std::false_type {};
|
|
|
|
|
|
|
|
|
@@ -88,7 +67,7 @@ struct is_shared: std::false_type {};
|
|
|
* @tparam Type Potentially shared type.
|
|
|
*/
|
|
|
template<typename Type>
|
|
|
-struct is_shared<shared_traits<Type>>: std::true_type {};
|
|
|
+struct is_shared<Type, std::void_t<typename shared_traits<std::decay_t<Type>>::type>>: std::true_type {};
|
|
|
|
|
|
|
|
|
/**
|
|
|
@@ -105,4 +84,35 @@ constexpr auto is_shared_v = is_shared<Type>::value;
|
|
|
}
|
|
|
|
|
|
|
|
|
+/**
|
|
|
+ * @brief Makes an already existing type a shared type.
|
|
|
+ * @param type Type to make shareable.
|
|
|
+ */
|
|
|
+#define ENTT_SHARED_TYPE(type)\
|
|
|
+ template<>\
|
|
|
+ struct entt::shared_traits<type>\
|
|
|
+ : std::integral_constant<typename entt::hashed_string::hash_type, entt::hashed_string::to_value(#type)>\
|
|
|
+ {}
|
|
|
+
|
|
|
+
|
|
|
+/**
|
|
|
+ * @brief Defines a type as shareable (to use for structs).
|
|
|
+ * @param clazz Name of the type to make shareable.
|
|
|
+ */
|
|
|
+#define ENTT_SHARED_STRUCT(clazz)\
|
|
|
+ struct clazz;\
|
|
|
+ ENTT_SHARED_TYPE(clazz)\
|
|
|
+ struct clazz
|
|
|
+
|
|
|
+
|
|
|
+/**
|
|
|
+ * @brief Defines a type as shareable (to use for classes).
|
|
|
+ * @param clazz Name of the type to make shareable.
|
|
|
+ */
|
|
|
+#define ENTT_SHARED_CLASS(clazz)\
|
|
|
+ class clazz;\
|
|
|
+ ENTT_SHARED_TYPE(clazz)\
|
|
|
+ class clazz
|
|
|
+
|
|
|
+
|
|
|
#endif // ENTT_CORE_TYPE_TRAITS_HPP
|