diff --git a/CMakeLists.txt b/CMakeLists.txt index 014aa9c18..911f5d7a9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -169,7 +169,6 @@ if(ENTT_INCLUDE_HEADERS) meta/meta.hpp meta/node.hpp meta/pointer.hpp - meta/policy.hpp meta/range.hpp meta/resolve.hpp meta/template.hpp diff --git a/src/entt/entt.hpp b/src/entt/entt.hpp index 43186e201..9464b12b3 100644 --- a/src/entt/entt.hpp +++ b/src/entt/entt.hpp @@ -50,7 +50,6 @@ namespace entt {} #include "meta/meta.hpp" #include "meta/node.hpp" #include "meta/pointer.hpp" -#include "meta/policy.hpp" #include "meta/range.hpp" #include "meta/resolve.hpp" #include "meta/template.hpp" diff --git a/src/entt/meta/factory.hpp b/src/entt/meta/factory.hpp index b1c3c6709..d61b36925 100644 --- a/src/entt/meta/factory.hpp +++ b/src/entt/meta/factory.hpp @@ -19,7 +19,6 @@ #include "fwd.hpp" #include "meta.hpp" #include "node.hpp" -#include "policy.hpp" #include "range.hpp" #include "resolve.hpp" #include "utility.hpp" @@ -252,15 +251,13 @@ public: * type is a built-in one or not. * * @tparam Candidate The actual function to use as a constructor. - * @tparam Policy Optional policy (no policy set by default). * @return A meta factory for the parent type. */ - template + template meta_factory ctor() noexcept { using descriptor = meta_function_helper_t; - static_assert(Policy::template value, "Invalid return type for the given policy"); static_assert(std::is_same_v>, Type>, "The function doesn't return an object of the required type"); - base_type::insert_or_assign(internal::meta_ctor_node{type_id().hash(), descriptor::args_type::size, &meta_arg, &meta_construct}); + base_type::insert_or_assign(internal::meta_ctor_node{type_id().hash(), descriptor::args_type::size, &meta_arg, &meta_construct}); return *this; } @@ -288,13 +285,12 @@ public: /** * @brief Assigns a meta data to a meta type. * @tparam Data The actual variable to attach to the meta type. - * @tparam Policy Optional policy (no policy set by default). * @param name A custom unique identifier as a **string literal**. * @return A meta factory for the given type. */ - template + template meta_factory data(const char *name) noexcept { - return data(entt::hashed_string::value(name), name); + return data(entt::hashed_string::value(name), name); } /** @@ -306,16 +302,14 @@ public: * reflected object will appear as if they were part of the type itself. * * @tparam Data The actual variable to attach to the meta type. - * @tparam Policy Optional policy (no policy set by default). * @param id Unique identifier. * @param name An optional name for the meta data as a **string literal**. * @return A meta factory for the parent type. */ - template + template meta_factory data(const id_type id, const char *name = nullptr) noexcept { if constexpr(std::is_member_object_pointer_v) { using data_type = std::invoke_result_t; - static_assert(Policy::template value, "Invalid return type for the given policy"); base_type::data( internal::meta_data_node{ @@ -327,16 +321,10 @@ public: &internal::resolve>>, &meta_arg>>>, &meta_setter, - &meta_getter}); + &meta_getter}); } else { using data_type = std::remove_pointer_t; - if constexpr(std::is_pointer_v) { - static_assert(Policy::template value, "Invalid return type for the given policy"); - } else { - static_assert(Policy::template value, "Invalid return type for the given policy"); - } - base_type::data( internal::meta_data_node{ id, @@ -346,7 +334,7 @@ public: &internal::resolve>>, &meta_arg>>>, &meta_setter, - &meta_getter}); + &meta_getter}); } return *this; @@ -357,13 +345,12 @@ public: * getter. * @tparam Setter The actual function to use as a setter. * @tparam Getter The actual function to use as a getter. - * @tparam Policy Optional policy (no policy set by default). * @param name A custom unique identifier as a **string literal**. * @return A meta factory for the given type. */ - template + template meta_factory data(const char *name) noexcept { - return data(entt::hashed_string::value(name), name); + return data(entt::hashed_string::value(name), name); } /** @@ -382,15 +369,13 @@ public: * * @tparam Setter The actual function to use as a setter. * @tparam Getter The actual function to use as a getter. - * @tparam Policy Optional policy (no policy set by default). * @param id Unique identifier. * @param name An optional name for the meta data as a **string literal**. * @return A meta factory for the parent type. */ - template + template meta_factory data(const id_type id, const char *name = nullptr) noexcept { using descriptor = meta_function_helper_t; - static_assert(Policy::template value, "Invalid return type for the given policy"); if constexpr(std::is_same_v) { base_type::data( @@ -403,7 +388,7 @@ public: &internal::resolve>>, &meta_arg>, &meta_setter, - &meta_getter}); + &meta_getter}); } else { using args_type = typename meta_function_helper_t::args_type; @@ -417,7 +402,7 @@ public: &internal::resolve>>, &meta_arg(args_type::size != 1u), args_type>>>, &meta_setter, - &meta_getter}); + &meta_getter}); } return *this; @@ -426,13 +411,12 @@ public: /** * @brief Assigns a meta function to a meta type. * @tparam Candidate The actual function to attach to the meta function. - * @tparam Policy Optional policy (no policy set by default). * @param name A custom unique identifier as a **string literal**. * @return A meta factory for the given type. */ - template + template meta_factory func(const char *name) noexcept { - return func(entt::hashed_string::value(name), name); + return func(entt::hashed_string::value(name), name); } /** @@ -444,15 +428,13 @@ public: * reflected object will appear as if they were part of the type itself. * * @tparam Candidate The actual function to attach to the meta type. - * @tparam Policy Optional policy (no policy set by default). * @param id Unique identifier. * @param name An optional name for the function as a **string literal**. * @return A meta factory for the parent type. */ - template + template meta_factory func(const id_type id, const char *name = nullptr) noexcept { using descriptor = meta_function_helper_t; - static_assert(Policy::template value, "Invalid return type for the given policy"); base_type::func( internal::meta_func_node{ @@ -460,9 +442,9 @@ public: name, (descriptor::is_const ? internal::meta_traits::is_const : internal::meta_traits::is_none) | (descriptor::is_static ? internal::meta_traits::is_static : internal::meta_traits::is_none), descriptor::args_type::size, - &internal::resolve, void, std::remove_cv_t>>>, + &internal::resolve>>, &meta_arg, - &meta_invoke}); + &meta_invoke}); return *this; } diff --git a/src/entt/meta/policy.hpp b/src/entt/meta/policy.hpp deleted file mode 100644 index b939599de..000000000 --- a/src/entt/meta/policy.hpp +++ /dev/null @@ -1,58 +0,0 @@ -#ifndef ENTT_META_POLICY_HPP -#define ENTT_META_POLICY_HPP - -#include - -namespace entt { - -/*! @brief Empty class type used to request the _as ref_ policy. */ -struct as_ref_t final { - /*! @cond TURN_OFF_DOXYGEN */ - template - static constexpr bool value = std::is_reference_v && !std::is_const_v>; - /*! @endcond */ -}; - -/*! @brief Empty class type used to request the _as cref_ policy. */ -struct as_cref_t final { - /*! @cond TURN_OFF_DOXYGEN */ - template - static constexpr bool value = std::is_reference_v; - /*! @endcond */ -}; - -/*! @brief Empty class type used to request the _as-is_ policy. */ -struct as_is_t final { - /*! @cond TURN_OFF_DOXYGEN */ - template - static constexpr bool value = true; - /*! @endcond */ -}; - -/*! @brief Empty class type used to request the _as void_ policy. */ -struct as_void_t final { - /*! @cond TURN_OFF_DOXYGEN */ - template - static constexpr bool value = true; - /*! @endcond */ -}; - -/** - * @brief Provides the member constant `value` to true if a type also is a meta - * policy, false otherwise. - * @tparam Type Type to check. - */ -template -struct is_meta_policy - : std::bool_constant || std::is_same_v || std::is_same_v || std::is_same_v> {}; - -/** - * @brief Helper variable template. - * @tparam Type Type to check. - */ -template -inline constexpr bool is_meta_policy_v = is_meta_policy::value; - -} // namespace entt - -#endif diff --git a/src/entt/meta/utility.hpp b/src/entt/meta/utility.hpp index 1648b011f..28e1e4cb4 100644 --- a/src/entt/meta/utility.hpp +++ b/src/entt/meta/utility.hpp @@ -9,7 +9,6 @@ #include "../locator/locator.hpp" #include "meta.hpp" #include "node.hpp" -#include "policy.hpp" namespace entt { @@ -77,7 +76,7 @@ template struct meta_function_descriptor : meta_function_descriptor_traits< Ret &, - std::conditional_t, type_list<>, type_list>, + std::conditional_t, type_list, type_list>, !std::is_base_of_v, false> {}; @@ -152,73 +151,66 @@ template using meta_function_helper_t = typename meta_function_helper::type; /** - * @brief Wraps a value depending on the given policy. + * @brief Wraps a value and returns it. * * This function always returns a wrapped value in the requested context.
* Therefore, if the passed value is itself a wrapped object with a different * context, it undergoes a rebinding to the requested context. * - * @tparam Policy Optional policy (no policy set by default). * @tparam Type Type of value to wrap. * @param ctx The context from which to search for meta types. * @param value Value to wrap. * @return A meta any containing the returned value, if any. */ -template -[[nodiscard]] std::enable_if_t, meta_any> meta_dispatch(const meta_ctx &ctx, [[maybe_unused]] Type &&value) { - if constexpr(std::is_same_v) { - return meta_any{ctx, std::in_place_type}; - } else if constexpr(std::is_same_v) { - return meta_any{ctx, std::in_place_type, value}; - } else if constexpr(std::is_same_v) { - static_assert(std::is_lvalue_reference_v, "Invalid type"); - return meta_any{ctx, std::in_place_type &>, std::as_const(value)}; +template +[[nodiscard]] meta_any meta_dispatch(const meta_ctx &ctx, [[maybe_unused]] Type &&value) { + if constexpr(std::is_lvalue_reference_v && !std::is_same_v>, meta_any>) { + return meta_any{ctx, std::in_place_type, std::forward(value)}; } else { return meta_any{ctx, std::forward(value)}; } } /** - * @brief Wraps a value depending on the given policy. - * @tparam Policy Optional policy (no policy set by default). + * @brief Wraps a value and returns it. * @tparam Type Type of value to wrap. * @param value Value to wrap. * @return A meta any containing the returned value, if any. */ -template -[[nodiscard]] std::enable_if_t, meta_any> meta_dispatch(Type &&value) { - return meta_dispatch(locator::value_or(), std::forward(value)); +template +[[nodiscard]] meta_any meta_dispatch(Type &&value) { + return meta_dispatch(locator::value_or(), std::forward(value)); } /*! @cond TURN_OFF_DOXYGEN */ namespace internal { -template +template [[nodiscard]] meta_any meta_invoke_with_args(const meta_ctx &ctx, Candidate &&candidate, Args &&...args) { if constexpr(std::is_void_v(candidate), args...))>) { std::invoke(std::forward(candidate), args...); return meta_any{ctx, std::in_place_type}; } else { - return meta_dispatch(ctx, std::invoke(std::forward(candidate), args...)); + return meta_dispatch(ctx, std::invoke(std::forward(candidate), args...)); } } -template +template [[nodiscard]] meta_any meta_invoke(meta_handle &instance, Candidate &&candidate, [[maybe_unused]] meta_any *const args, std::index_sequence) { using descriptor = meta_function_helper_t>; // NOLINTBEGIN(cppcoreguidelines-pro-bounds-pointer-arithmetic) - waiting for C++20 (and std::span) if constexpr(std::is_invocable_v, const Type &, type_list_element_t...>) { if(const auto *const clazz = instance->try_cast(); clazz && ((args + Index)->allow_cast>() && ...)) { - return meta_invoke_with_args(instance->context(), std::forward(candidate), *clazz, (args + Index)->cast>()...); + return meta_invoke_with_args(instance->context(), std::forward(candidate), *clazz, (args + Index)->cast>()...); } } else if constexpr(std::is_invocable_v, Type &, type_list_element_t...>) { if(auto *const clazz = instance->try_cast(); clazz && ((args + Index)->allow_cast>() && ...)) { - return meta_invoke_with_args(instance->context(), std::forward(candidate), *clazz, (args + Index)->cast>()...); + return meta_invoke_with_args(instance->context(), std::forward(candidate), *clazz, (args + Index)->cast>()...); } } else { if(((args + Index)->allow_cast>() && ...)) { - return meta_invoke_with_args(instance->context(), std::forward(candidate), (args + Index)->cast>()...); + return meta_invoke_with_args(instance->context(), std::forward(candidate), (args + Index)->cast>()...); } } // NOLINTEND(cppcoreguidelines-pro-bounds-pointer-arithmetic) @@ -309,23 +301,22 @@ template * @brief Gets the value of a given variable. * @tparam Type Reflected type to which the variable is associated. * @tparam Data The actual variable to get. - * @tparam Policy Optional policy (no policy set by default). * @param instance An opaque instance of the underlying type, if required. * @return A meta any containing the value of the underlying variable. */ -template -[[nodiscard]] std::enable_if_t, meta_any> meta_getter(meta_handle instance) { +template +[[nodiscard]] meta_any meta_getter(meta_handle instance) { if constexpr(std::is_member_pointer_v || std::is_function_v>>) { if constexpr(!std::is_array_v>>>) { if constexpr(std::is_invocable_v) { if(auto *clazz = instance->try_cast(); clazz) { - return meta_dispatch(instance->context(), std::invoke(Data, *clazz)); + return internal::meta_invoke_with_args(instance->context(), Data, *clazz); } } if constexpr(std::is_invocable_v) { if(auto *fallback = instance->try_cast(); fallback) { - return meta_dispatch(instance->context(), std::invoke(Data, *fallback)); + return internal::meta_invoke_with_args(instance->context(), Data, *fallback); } } } @@ -335,40 +326,38 @@ template if constexpr(std::is_array_v>) { return meta_any{meta_ctx_arg, instance->context()}; } else { - return meta_dispatch(instance->context(), *Data); + return meta_dispatch(instance->context(), *Data); } } else { - return meta_dispatch(instance->context(), Data); + return meta_dispatch(instance->context(), Data); } } /** * @brief Tries to _invoke_ an object given a list of erased parameters. * @tparam Type Reflected type to which the object to _invoke_ is associated. - * @tparam Policy Optional policy (no policy set by default). * @tparam Candidate The type of the actual object to _invoke_. * @param instance An opaque instance of the underlying type, if required. * @param candidate The actual object to _invoke_. * @param args Parameters to use to _invoke_ the object. * @return A meta any containing the returned value, if any. */ -template -[[nodiscard]] std::enable_if_t, meta_any> meta_invoke(meta_handle instance, Candidate &&candidate, meta_any *const args) { - return internal::meta_invoke(instance, std::forward(candidate), args, std::make_index_sequence>::args_type::size>{}); +template +[[nodiscard]] meta_any meta_invoke(meta_handle instance, Candidate &&candidate, meta_any *const args) { + return internal::meta_invoke(instance, std::forward(candidate), args, std::make_index_sequence>::args_type::size>{}); } /** * @brief Tries to invoke a function given a list of erased parameters. * @tparam Type Reflected type to which the function is associated. * @tparam Candidate The actual function to invoke. - * @tparam Policy Optional policy (no policy set by default). * @param instance An opaque instance of the underlying type, if required. * @param args Parameters to use to invoke the function. * @return A meta any containing the returned value, if any. */ -template -[[nodiscard]] std::enable_if_t, meta_any> meta_invoke(meta_handle instance, meta_any *const args) { - return internal::meta_invoke(instance, Candidate, args, std::make_index_sequence>::args_type::size>{}); +template +[[nodiscard]] meta_any meta_invoke(meta_handle instance, meta_any *const args) { + return internal::meta_invoke(instance, Candidate, args, std::make_index_sequence>::args_type::size>{}); } /** @@ -409,37 +398,35 @@ template * It's up to the caller to bind the arguments to the right context(s). * * @tparam Type Reflected type to which the object to _invoke_ is associated. - * @tparam Policy Optional policy (no policy set by default). * @tparam Candidate The type of the actual object to _invoke_. * @param ctx The context from which to search for meta types. * @param candidate The actual object to _invoke_. * @param args Parameters to use to _invoke_ the object. * @return A meta any containing the returned value, if any. */ -template +template [[nodiscard]] meta_any meta_construct(const meta_ctx &ctx, Candidate &&candidate, meta_any *const args) { if constexpr(meta_function_helper_t::is_static || std::is_class_v>>) { meta_handle placeholder{meta_ctx_arg, ctx}; - return internal::meta_invoke(placeholder, std::forward(candidate), args, std::make_index_sequence>::args_type::size>{}); + return internal::meta_invoke(placeholder, std::forward(candidate), args, std::make_index_sequence>::args_type::size>{}); } else { meta_handle target{*args}; // NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-pointer-arithmetic) - waiting for C++20 (and std::span) - return internal::meta_invoke(target, std::forward(candidate), args + 1u, std::make_index_sequence>::args_type::size>{}); + return internal::meta_invoke(target, std::forward(candidate), args + 1u, std::make_index_sequence>::args_type::size>{}); } } /** * @brief Tries to construct an instance given a list of erased parameters. * @tparam Type Reflected type to which the object to _invoke_ is associated. - * @tparam Policy Optional policy (no policy set by default). * @tparam Candidate The type of the actual object to _invoke_. * @param candidate The actual object to _invoke_. * @param args Parameters to use to _invoke_ the object. * @return A meta any containing the returned value, if any. */ -template -[[nodiscard]] std::enable_if_t, meta_any> meta_construct(Candidate &&candidate, meta_any *const args) { - return meta_construct(locator::value_or(), std::forward(candidate), args); +template +[[nodiscard]] meta_any meta_construct(Candidate &&candidate, meta_any *const args) { + return meta_construct(locator::value_or(), std::forward(candidate), args); } /** @@ -451,27 +438,25 @@ template * * @tparam Type Reflected type to which the function is associated. * @tparam Candidate The actual function to invoke. - * @tparam Policy Optional policy (no policy set by default). * @param ctx The context from which to search for meta types. * @param args Parameters to use to invoke the function. * @return A meta any containing the returned value, if any. */ -template -[[nodiscard]] std::enable_if_t, meta_any> meta_construct(const meta_ctx &ctx, meta_any *const args) { - return meta_construct(ctx, Candidate, args); +template +[[nodiscard]] meta_any meta_construct(const meta_ctx &ctx, meta_any *const args) { + return meta_construct(ctx, Candidate, args); } /** * @brief Tries to construct an instance given a list of erased parameters. * @tparam Type Reflected type to which the function is associated. * @tparam Candidate The actual function to invoke. - * @tparam Policy Optional policy (no policy set by default). * @param args Parameters to use to invoke the function. * @return A meta any containing the returned value, if any. */ -template -[[nodiscard]] std::enable_if_t, meta_any> meta_construct(meta_any *const args) { - return meta_construct(locator::value_or(), args); +template +[[nodiscard]] meta_any meta_construct(meta_any *const args) { + return meta_construct(locator::value_or(), args); } } // namespace entt diff --git a/test/entt/meta/meta_ctor.cpp b/test/entt/meta/meta_ctor.cpp index f8e89f06c..837f31469 100644 --- a/test/entt/meta/meta_ctor.cpp +++ b/test/entt/meta/meta_ctor.cpp @@ -7,7 +7,6 @@ #include #include #include -#include #include struct base { @@ -60,7 +59,7 @@ struct MetaCtor: ::testing::Test { entt::meta_factory{} .type("clazz"_hs) - .ctor<&entt::registry::emplace_or_replace, entt::as_ref_t>() + .ctor<&entt::registry::emplace_or_replace>() .ctor() .ctor() .ctor(clazz::factory)>() diff --git a/test/entt/meta/meta_data.cpp b/test/entt/meta/meta_data.cpp index eebcb8f3d..fbb10e84c 100644 --- a/test/entt/meta/meta_data.cpp +++ b/test/entt/meta/meta_data.cpp @@ -9,7 +9,6 @@ #include #include #include -#include #include #include #include "../../common/config.h" @@ -67,6 +66,17 @@ struct array { int local[4]; // NOLINT }; +// waiting for C++20 and lambdas inlined as template arguments +namespace { + +const int &clazz_i_as_const_reference(const clazz &elem) { + return elem.i; +} + +void clazz_i_as_void(const clazz &) {} + +} // namespace + struct MetaData: ::testing::Test { void SetUp() override { using namespace entt::literals; @@ -82,10 +92,10 @@ struct MetaData: ::testing::Test { entt::meta_factory{} .type("clazz"_hs) - .data<&clazz::i, entt::as_ref_t>("i"_hs) + .data<&clazz::i>("i"_hs) .custom('c') .traits(test::meta_traits::one | test::meta_traits::two | test::meta_traits::three) - .data<&clazz::i, entt::as_cref_t>("ci"_hs) + .data<&clazz::i, &clazz_i_as_const_reference>("ci"_hs) .data<&clazz::j>("j") .traits(test::meta_traits::one) .data<&clazz::h>("h"_hs, "hhh") @@ -94,7 +104,7 @@ struct MetaData: ::testing::Test { .traits(test::meta_traits::three) .data<'c'>("l"_hs) .data<&clazz::instance>("base"_hs) - .data<&clazz::i, entt::as_void_t>("void"_hs) + .data<&clazz::i, clazz_i_as_void>("void"_hs) .conv(); entt::meta_factory{} @@ -534,7 +544,7 @@ TEST_F(MetaData, AsVoid) { ASSERT_TRUE(data); ASSERT_EQ(data.arity(), 1u); - ASSERT_EQ(data.type(), entt::resolve()); + ASSERT_EQ(data.type(), entt::resolve()); ASSERT_EQ(data.arg(0u), entt::resolve()); ASSERT_TRUE(data.set(instance, 1)); ASSERT_EQ(instance.i, 1); diff --git a/test/entt/meta/meta_func.cpp b/test/entt/meta/meta_func.cpp index 3f0a3c6b7..d83f4a8c7 100644 --- a/test/entt/meta/meta_func.cpp +++ b/test/entt/meta/meta_func.cpp @@ -7,7 +7,6 @@ #include #include #include -#include #include #include #include "../../common/config.h" @@ -89,6 +88,19 @@ double double_member(const double &value) { return value * value; } +// waiting for C++20 and lambdas inlined as template arguments +namespace { + +void elem_v_as_void(const function &elem, int &iv) { + static_cast(elem.v(iv)); +} + +const int &elem_a_as_const(function &elem) { + return elem.a(); +} + +} // namespace + struct MetaFunc: ::testing::Test { void SetUp() override { using namespace entt::literals; @@ -112,7 +124,7 @@ struct MetaFunc: ::testing::Test { entt::meta_factory{} .type("func"_hs) - .func<&entt::registry::emplace_or_replace, entt::as_ref_t>("emplace"_hs) + .func<&entt::registry::emplace_or_replace>("emplace"_hs) .traits(test::meta_traits::one | test::meta_traits::two | test::meta_traits::three) .func(&function::f)>("f3"_hs) .traits(test::meta_traits::three) @@ -125,9 +137,9 @@ struct MetaFunc: ::testing::Test { .custom('c') .func("h"_hs) .func("k"_hs) - .func<&function::v, entt::as_void_t>("v"_hs) - .func<&function::a, entt::as_ref_t>("a"_hs) - .func<&function::a, entt::as_cref_t>("ca"_hs) + .func<&elem_v_as_void>("v"_hs) + .func<&function::a>("a"_hs) + .func<&elem_a_as_const>("ca"_hs) .conv(); } diff --git a/test/entt/meta/meta_utility.cpp b/test/entt/meta/meta_utility.cpp index e8cab8cf5..7ae9133f5 100644 --- a/test/entt/meta/meta_utility.cpp +++ b/test/entt/meta/meta_utility.cpp @@ -4,7 +4,6 @@ #include #include #include -#include #include #include #include "../../common/config.h" @@ -59,22 +58,20 @@ using MetaUtilityDeathTest = MetaUtility; TEST_F(MetaUtility, MetaDispatch) { int value = 2; - auto as_void = entt::meta_dispatch(value); - auto as_ref = entt::meta_dispatch(value); - auto as_cref = entt::meta_dispatch(value); - auto as_is = entt::meta_dispatch(value); + auto as_ref = entt::meta_dispatch(value); + auto as_cref = entt::meta_dispatch(std::as_const(value)); + auto as_copy = entt::meta_dispatch(static_cast(value)); - ASSERT_EQ(as_void.type(), entt::resolve()); ASSERT_EQ(as_ref.type(), entt::resolve()); ASSERT_EQ(as_cref.type(), entt::resolve()); - ASSERT_EQ(as_is.type(), entt::resolve()); + ASSERT_EQ(as_copy.type(), entt::resolve()); - ASSERT_NE(as_is.try_cast(), nullptr); + ASSERT_NE(as_copy.try_cast(), nullptr); ASSERT_NE(as_ref.try_cast(), nullptr); ASSERT_EQ(as_cref.try_cast(), nullptr); ASSERT_NE(as_cref.try_cast(), nullptr); - ASSERT_EQ(as_is.cast(), 2); + ASSERT_EQ(as_copy.cast(), 2); ASSERT_EQ(as_ref.cast(), 2); ASSERT_EQ(as_cref.cast(), 2); } diff --git a/test/example/entity_copy.cpp b/test/example/entity_copy.cpp index 51351869e..409294826 100644 --- a/test/example/entity_copy.cpp +++ b/test/example/entity_copy.cpp @@ -5,7 +5,6 @@ #include #include #include -#include #include enum class my_entity : entt::id_type {}; @@ -31,9 +30,9 @@ meta_mixin::meta_mixin(const allocator_type &allocator) entt::meta_factory{} // cross registry, same type - .template func &(const entt::id_type)>(&entt::basic_registry::storage), entt::as_ref_t>("storage"_hs) + .template func &(const entt::id_type)>(&entt::basic_registry::storage)>("storage"_hs) // cross registry, different types - .template func &(const entt::id_type)>(&entt::basic_registry::storage), entt::as_ref_t>("storage"_hs); + .template func &(const entt::id_type)>(&entt::basic_registry::storage)>("storage"_hs); } template