|
|
@@ -9,9 +9,89 @@
|
|
|
namespace entt {
|
|
|
|
|
|
|
|
|
-/*! @brief A class to use to push around lists of types, nothing more. */
|
|
|
+/**
|
|
|
+ * @brief A class to use to push around lists of types, nothing more.
|
|
|
+ * @tparam Type Types provided by the given type list.
|
|
|
+ */
|
|
|
template<typename... Type>
|
|
|
-struct type_list {};
|
|
|
+struct type_list {
|
|
|
+ /*! @brief Unsigned integer type. */
|
|
|
+ static constexpr auto size = sizeof...(Type);
|
|
|
+};
|
|
|
+
|
|
|
+
|
|
|
+/*! @brief Primary template isn't defined on purpose. */
|
|
|
+template<typename...>
|
|
|
+struct type_list_cat;
|
|
|
+
|
|
|
+
|
|
|
+/**
|
|
|
+ * @brief Concatenates multiple type lists.
|
|
|
+ * @tparam Type Types provided by the first type list.
|
|
|
+ * @tparam Other Types provided by the second type list.
|
|
|
+ * @tparam List Other type lists, if any.
|
|
|
+ */
|
|
|
+template<typename... Type, typename... Other, typename... List>
|
|
|
+struct type_list_cat<type_list<Type...>, type_list<Other...>, List...> {
|
|
|
+ /*! @brief A type list composed by the types of all the type lists. */
|
|
|
+ using type = typename type_list_cat<type_list<Type..., Other...>, List...>::type;
|
|
|
+};
|
|
|
+
|
|
|
+
|
|
|
+/**
|
|
|
+ * @brief Concatenates multiple type lists.
|
|
|
+ * @tparam Type Types provided by the type list.
|
|
|
+ */
|
|
|
+template<typename... Type>
|
|
|
+struct type_list_cat<type_list<Type...>> {
|
|
|
+ /*! @brief A type list composed by the types of all the type lists. */
|
|
|
+ using type = type_list<Type...>;
|
|
|
+};
|
|
|
+
|
|
|
+
|
|
|
+/**
|
|
|
+ * @brief Helper type.
|
|
|
+ * @tparam List Type lists to concatenate.
|
|
|
+ */
|
|
|
+template<typename... List>
|
|
|
+using type_list_cat_t = typename type_list_cat<List...>::type;
|
|
|
+
|
|
|
+
|
|
|
+/*! @brief Primary template isn't defined on purpose. */
|
|
|
+template<typename>
|
|
|
+struct type_list_unique;
|
|
|
+
|
|
|
+
|
|
|
+/**
|
|
|
+ * @brief Removes duplicates types from a type list.
|
|
|
+ * @tparam Type One of the types provided by the given type list.
|
|
|
+ * @tparam Other The other types provided by the given type list.
|
|
|
+ */
|
|
|
+template<typename Type, typename... Other>
|
|
|
+struct type_list_unique<type_list<Type, Other...>> {
|
|
|
+ /*! @brief A type list without duplicate types. */
|
|
|
+ using type = std::conditional_t<
|
|
|
+ std::disjunction_v<std::is_same<Type, Other>...>,
|
|
|
+ typename type_list_unique<type_list<Other...>>::type,
|
|
|
+ type_list_cat_t<type_list<Type>, typename type_list_unique<type_list<Other...>>::type>
|
|
|
+ >;
|
|
|
+};
|
|
|
+
|
|
|
+
|
|
|
+/*! @brief Removes duplicates types from a type list. */
|
|
|
+template<>
|
|
|
+struct type_list_unique<type_list<>> {
|
|
|
+ /*! @brief A type list without duplicate types. */
|
|
|
+ using type = type_list<>;
|
|
|
+};
|
|
|
+
|
|
|
+
|
|
|
+/**
|
|
|
+ * @brief Helper type.
|
|
|
+ * @tparam Type A type list.
|
|
|
+ */
|
|
|
+template<typename Type>
|
|
|
+using type_list_unique_t = typename type_list_unique<Type>::type;
|
|
|
|
|
|
|
|
|
/*! @brief Traits class used mainly to push things across boundaries. */
|