From 03bf0f90b438d23a3c91dbc3cda4dd9e320e7d18 Mon Sep 17 00:00:00 2001 From: skypjack Date: Thu, 6 Nov 2025 00:16:15 +0100 Subject: [PATCH] meta: minor changes --- src/entt/meta/meta.hpp | 26 +++++++++++--------------- 1 file changed, 11 insertions(+), 15 deletions(-) diff --git a/src/entt/meta/meta.hpp b/src/entt/meta/meta.hpp index 7c7c16e2b..0dd2d1ab9 100644 --- a/src/entt/meta/meta.hpp +++ b/src/entt/meta/meta.hpp @@ -209,6 +209,12 @@ class meta_any { return *node; } + meta_any(const meta_any &other, any elem) + : storage{std::move(elem)}, + ctx{other.ctx}, + node{other.node}, + vtable{other.vtable} {} + public: /*! Default constructor. */ meta_any() = default; @@ -261,10 +267,8 @@ public: template explicit meta_any(const meta_ctx &area, std::in_place_t, Type *value) : storage{std::in_place, value}, - ctx{&area} { - if(storage) { - vtable = &basic_vtable; - } + ctx{&area}, + vtable{storage ? &basic_vtable : nullptr} { } /** @@ -605,20 +609,12 @@ public: /*! @copydoc any::as_ref */ [[nodiscard]] meta_any as_ref() noexcept { - meta_any other{meta_ctx_arg, *ctx}; - other.storage = storage.as_ref(); - other.node = node; - other.vtable = vtable; - return other; + return meta_any{*this, storage.as_ref()}; } /*! @copydoc any::as_ref */ [[nodiscard]] meta_any as_ref() const noexcept { - meta_any other{meta_ctx_arg, *ctx}; - other.storage = storage.as_ref(); - other.node = node; - other.vtable = vtable; - return other; + return meta_any{*this, storage.as_ref()}; } /** @@ -781,7 +777,7 @@ struct meta_custom { */ template [[nodiscard]] operator Type &() const noexcept { - ENTT_ASSERT((node != nullptr) && (type_hash>::value() == node->type), "Invalid type"); + ENTT_ASSERT(static_cast(*this) != nullptr, "Invalid type"); return *static_cast(node->value.get()); }