meta: reintroduce as_ref constructor

This commit is contained in:
Michele Caini
2022-10-09 10:46:17 +02:00
parent 0d4674d8e2
commit 2d2e4c784e

View File

@@ -187,6 +187,12 @@ class meta_any {
}
}
meta_any(const meta_any &other, any ref, const meta_ctx &area) noexcept
: storage{std::move(ref)},
ctx{&area},
node{storage ? other.node : internal::meta_type_node{}},
vtable{storage ? other.vtable : &basic_vtable<void>} {}
public:
/**
* @brief Context aware constructor.
@@ -531,20 +537,12 @@ public:
/*! @copydoc any::as_ref */
[[nodiscard]] meta_any as_ref() noexcept {
meta_any other{};
other.storage = storage.as_ref();
other.node = storage ? node : other.node;
other.vtable = vtable;
return other;
return meta_any{*this, storage.as_ref(), *ctx};
}
/*! @copydoc any::as_ref */
[[nodiscard]] meta_any as_ref() const noexcept {
meta_any other{};
other.storage = storage.as_ref();
other.node = storage ? node : other.node;
other.vtable = vtable;
return other;
return meta_any{*this, storage.as_ref(), *ctx};
}
/*! @copydoc any::owner */