diff --git a/src/entt/meta/meta.hpp b/src/entt/meta/meta.hpp index 9e5ec4e2f..066ef3823 100644 --- a/src/entt/meta/meta.hpp +++ b/src/entt/meta/meta.hpp @@ -1245,7 +1245,7 @@ public: * false otherwise. */ [[nodiscard]] bool is_template_specialization() const ENTT_NOEXCEPT { - return node->template_info.is_template_specialization; + return (node->templ != nullptr); } /** @@ -1253,7 +1253,7 @@ public: * @return The number of template arguments, if any. */ [[nodiscard]] size_type template_arity() const ENTT_NOEXCEPT { - return node->template_info.arity; + return node->templ ? node->templ->arity : size_type{}; } /** @@ -1264,7 +1264,7 @@ public: * @return The tag for the class template of the underlying type. */ [[nodiscard]] inline meta_type template_type() const ENTT_NOEXCEPT { - return is_template_specialization() ? node->template_info.type() : meta_type{}; + return node->templ ? node->templ->type() : meta_type{}; } /** @@ -1273,7 +1273,7 @@ public: * @return The type of the i-th template argument of a type. */ [[nodiscard]] inline meta_type template_arg(size_type index) const ENTT_NOEXCEPT { - return index < template_arity() ? node->template_info.arg(index) : meta_type{}; + return index < template_arity() ? node->templ->arg(index) : meta_type{}; } /** diff --git a/src/entt/meta/node.hpp b/src/entt/meta/node.hpp index 3681d6f05..608eba482 100644 --- a/src/entt/meta/node.hpp +++ b/src/entt/meta/node.hpp @@ -95,9 +95,8 @@ struct meta_func_node { }; -struct meta_template_info { +struct meta_template_node { using size_type = std::size_t; - const bool is_template_specialization; const size_type arity; meta_type_node *(* const type)() ENTT_NOEXCEPT; meta_type_node *(* const arg)(const size_type) ENTT_NOEXCEPT; @@ -125,11 +124,11 @@ struct meta_type_node { const bool is_pointer_like; const bool is_sequence_container; const bool is_associative_container; - const meta_template_info template_info; const size_type rank; size_type(* const extent)(const size_type) ENTT_NOEXCEPT ; meta_type_node *(* const remove_pointer)() ENTT_NOEXCEPT; meta_type_node *(* const remove_extent)() ENTT_NOEXCEPT; + const meta_template_node *const templ; meta_ctor_node * const def_ctor; meta_ctor_node *ctor{nullptr}; meta_base_node *base{nullptr}; @@ -193,18 +192,19 @@ class ENTT_API meta_node { } } - [[nodiscard]] static meta_template_info meta_template_descriptor() ENTT_NOEXCEPT { + [[nodiscard]] static meta_template_node * meta_template_info() ENTT_NOEXCEPT { if constexpr(is_complete_v>) { - return { - true, + static meta_template_node node{ meta_template_traits::args_type::size, &meta_node::class_type>::resolve, [](const std::size_t index) ENTT_NOEXCEPT { return meta_arg_node(typename meta_template_traits::args_type{}, index); } }; + + return &node; } else { - return { false, 0u, nullptr, nullptr }; + return nullptr; } } @@ -230,11 +230,11 @@ public: is_meta_pointer_like_v, is_complete_v>, is_complete_v>, - meta_template_descriptor(), std::rank_v, [](meta_type_node::size_type dim) ENTT_NOEXCEPT { return extent(dim, std::make_index_sequence>{}); }, &meta_node>>>::resolve, &meta_node>>>::resolve, + meta_template_info(), meta_default_constructor(&node), meta_default_constructor(&node) }; diff --git a/src/entt/meta/utility.hpp b/src/entt/meta/utility.hpp index 4a9d96606..1e77d3ddb 100644 --- a/src/entt/meta/utility.hpp +++ b/src/entt/meta/utility.hpp @@ -121,22 +121,22 @@ using meta_function_helper_t = typename meta_function_helper::t /** * @brief Wraps a value depending on the given policy. * @tparam Policy Optional policy (no policy set by default). - * @tparam Type Optional type of value to wrap. - * @param value Optional value to wrap. + * @tparam Type Type of value to wrap. + * @param value Value to wrap. * @return A meta any containing the returned value, if any. */ -template -meta_any meta_dispatch([[maybe_unused]] Type &&... value) { - if constexpr(std::is_same_v || !sizeof...(Type)) { +template +meta_any meta_dispatch([[maybe_unused]] Type &&value) { + if constexpr(std::is_same_v) { return meta_any{std::in_place_type}; } else if constexpr(std::is_same_v) { - return meta_any{std::in_place_type, std::forward(value)...}; + return meta_any{std::in_place_type, std::forward(value)}; } else if constexpr(std::is_same_v) { - static_assert(std::is_lvalue_reference_v, "Invalid type"); - return meta_any{std::in_place_type &...>, std::as_const(value)...}; + static_assert(std::is_lvalue_reference_v, "Invalid type"); + return meta_any{std::in_place_type &>, std::as_const(value)}; } else { static_assert(std::is_same_v, "Policy not supported"); - return meta_any{std::forward(value)...}; + return meta_any{std::forward(value)}; } } @@ -257,14 +257,14 @@ template) { if constexpr(std::is_void_v) { (std::forward(maybe_clazz).*Candidate)(std::forward(other)...); - return meta_dispatch(); + return meta_any{std::in_place_type}; } else { return meta_dispatch((std::forward(maybe_clazz).*Candidate)(std::forward(other)...)); } } else { if constexpr(std::is_void_v) { Candidate(std::forward(maybe_clazz), std::forward(other)...); - return meta_dispatch(); + return meta_any{std::in_place_type}; } else { return meta_dispatch(Candidate(std::forward(maybe_clazz), std::forward(other)...)); } @@ -322,7 +322,7 @@ template if constexpr(std::is_invocable_v) { if constexpr(std::is_void_v) { Candidate(); - return meta_dispatch(); + return meta_any{std::in_place_type}; } else { return meta_dispatch(Candidate()); }