From 660bc5843e6f5d01efcfa75604d76c28b9733a24 Mon Sep 17 00:00:00 2001 From: Michele Caini Date: Mon, 27 Mar 2023 11:15:35 +0200 Subject: [PATCH] entity: turn get_t, exclude_t and owned_t into proper classes (close #998) --- src/entt/entity/fwd.hpp | 39 ++++++++++++++++++++++++++++++++++++--- 1 file changed, 36 insertions(+), 3 deletions(-) diff --git a/src/entt/entity/fwd.hpp b/src/entt/entity/fwd.hpp index 0979cc419..7fe08912b 100644 --- a/src/entt/entity/fwd.hpp +++ b/src/entt/entity/fwd.hpp @@ -102,7 +102,7 @@ class basic_continuous_loader; * @tparam Type List of types. */ template -using exclude_t = type_list; +struct exclude_t final: type_list {}; /** * @brief Variable template for exclusion lists. @@ -116,7 +116,7 @@ inline constexpr exclude_t exclude{}; * @tparam Type List of types. */ template -using get_t = type_list; +struct get_t final: type_list {}; /** * @brief Variable template for lists of observed components. @@ -130,7 +130,7 @@ inline constexpr get_t get{}; * @tparam Type List of types. */ template -using owned_t = type_list; +struct owned_t final: type_list {}; /** * @brief Variable template for lists of owned components. @@ -139,6 +139,39 @@ using owned_t = type_list; template inline constexpr owned_t owned{}; +/** + * @brief Applies a given _function_ to a get list and generate a new list. + * @tparam Type Types provided by the get list. + * @tparam Op Unary operation as template class with a type member named `type`. + */ +template class Op> +struct type_list_transform, Op> { + /*! @brief Resulting get list after applying the transform function. */ + using type = get_t::type...>; +}; + +/** + * @brief Applies a given _function_ to an exclude list and generate a new list. + * @tparam Type Types provided by the exclude list. + * @tparam Op Unary operation as template class with a type member named `type`. + */ +template class Op> +struct type_list_transform, Op> { + /*! @brief Resulting exclude list after applying the transform function. */ + using type = exclude_t::type...>; +}; + +/** + * @brief Applies a given _function_ to an owned list and generate a new list. + * @tparam Type Types provided by the owned list. + * @tparam Op Unary operation as template class with a type member named `type`. + */ +template class Op> +struct type_list_transform, Op> { + /*! @brief Resulting owned list after applying the transform function. */ + using type = owned_t::type...>; +}; + /*! @brief Alias declaration for the most common use case. */ using sparse_set = basic_sparse_set<>;