diff --git a/src/entt/meta/meta.hpp b/src/entt/meta/meta.hpp index 5282078b3..8a2cffb9a 100644 --- a/src/entt/meta/meta.hpp +++ b/src/entt/meta/meta.hpp @@ -163,6 +163,11 @@ class meta_any { static void basic_vtable([[maybe_unused]] const internal::meta_traits req, [[maybe_unused]] const meta_ctx &area, [[maybe_unused]] const void *value, [[maybe_unused]] void *other) { static_assert(std::is_same_v>, Type>, "Invalid type"); + if(req == internal::meta_traits::is_none) { + const auto &self = *static_cast(value); + self.node = &internal::resolve(internal::meta_context::from(area)); + } + if constexpr(is_meta_pointer_like_v) { if(req == internal::meta_traits::is_pointer_like) { if constexpr(std::is_function_v::element_type>) { @@ -200,15 +205,18 @@ class meta_any { : storage{std::move(ref)}, ctx{other.ctx} { if(storage || !other.storage) { - resolve = other.resolve; node = other.node; vtable = other.vtable; } } [[nodiscard]] const auto &fetch_node() const { - ENTT_ASSERT(resolve != nullptr, "Invalid resolve function"); - return (node == nullptr) ? *(node = &resolve(internal::meta_context::from(*ctx))) : *node; + if(node == nullptr) { + ENTT_ASSERT(vtable != nullptr, "Invalid vtable function"); + vtable(internal::meta_traits::is_none, *ctx, this, nullptr); + } + + return *node; } public: @@ -243,7 +251,6 @@ public: explicit meta_any(const meta_ctx &area, std::in_place_type_t, Args &&...args) : storage{std::in_place_type, std::forward(args)...}, ctx{&area}, - resolve{&internal::resolve>>}, vtable{&basic_vtable>>} {} /** @@ -266,7 +273,6 @@ public: : storage{std::in_place, value}, ctx{&area} { if(storage) { - resolve = &internal::resolve; vtable = &basic_vtable; } } @@ -298,7 +304,6 @@ public: meta_any(const meta_ctx &area, const meta_any &other) : storage{other.storage}, ctx{&area}, - resolve{other.resolve}, node{(ctx == other.ctx) ? other.node : nullptr}, vtable{other.vtable} {} @@ -310,7 +315,6 @@ public: meta_any(const meta_ctx &area, meta_any &&other) : storage{std::move(other.storage)}, ctx{&area}, - resolve{std::exchange(other.resolve, nullptr)}, node{(ctx == other.ctx) ? std::exchange(other.node, nullptr) : nullptr}, vtable{std::exchange(other.vtable, nullptr)} {} @@ -327,7 +331,6 @@ public: meta_any(meta_any &&other) noexcept : storage{std::move(other.storage)}, ctx{other.ctx}, - resolve{std::exchange(other.resolve, nullptr)}, node{std::exchange(other.node, nullptr)}, vtable{std::exchange(other.vtable, nullptr)} {} @@ -343,7 +346,6 @@ public: if(this != &other) { storage = other.storage; ctx = other.ctx; - resolve = other.resolve; node = other.node; vtable = other.vtable; } @@ -359,7 +361,6 @@ public: meta_any &operator=(meta_any &&other) noexcept { storage = std::move(other.storage); ctx = other.ctx; - resolve = std::exchange(other.resolve, nullptr); node = std::exchange(other.node, nullptr); vtable = std::exchange(other.vtable, nullptr); return *this; @@ -506,12 +507,8 @@ public: template void emplace(Args &&...args) { storage.emplace(std::forward(args)...); - - if(auto *overload = &internal::resolve>>; overload != resolve) { - resolve = overload; - node = nullptr; - vtable = &basic_vtable>>; - } + node = nullptr; + vtable = &basic_vtable>>; } /*! @copydoc any::assign */ @@ -523,7 +520,6 @@ public: /*! @copydoc any::reset */ void reset() { storage.reset(); - resolve = nullptr; node = nullptr; vtable = nullptr; } @@ -620,7 +616,6 @@ public: private: any storage{}; const meta_ctx *ctx{&locator::value_or()}; - const internal::meta_type_node &(*resolve)(const internal::meta_context &) noexcept {}; mutable const internal::meta_type_node *node{}; vtable_type *vtable{}; };