diff --git a/src/entt/meta/factory.hpp b/src/entt/meta/factory.hpp
index dabd22815..c614fb379 100644
--- a/src/entt/meta/factory.hpp
+++ b/src/entt/meta/factory.hpp
@@ -75,11 +75,6 @@ protected:
}
}
- void dtor(meta_dtor_node node) {
- reset_bucket(parent);
- meta_context::from(*ctx).value[parent].dtor = node;
- }
-
void data(meta_data_node node) {
reset_bucket(node.id);
@@ -284,32 +279,6 @@ public:
return *this;
}
- /**
- * @brief Assigns a meta destructor to a meta type.
- *
- * Both free functions and member functions can be assigned to meta types in
- * the role of destructors.
- * The signature of a free function should be identical to the following:
- *
- * @code{.cpp}
- * void(Type &);
- * @endcode
- *
- * Member functions should not take arguments instead.
- * The purpose is to give users the ability to free up resources that
- * require special treatment before an object is actually destroyed.
- *
- * @tparam Func The actual function to use as a destructor.
- * @return A meta factory for the parent type.
- */
- template
- meta_factory dtor() noexcept {
- static_assert(std::is_invocable_v, "The function doesn't accept an object of the type provided");
- auto *const op = +[](void *instance) { std::invoke(Func, *static_cast(instance)); };
- base_type::dtor(internal::meta_dtor_node{op});
- return *this;
- }
-
/**
* @brief Assigns a meta data to a meta type.
* @tparam Data The actual variable to attach to the meta type.
diff --git a/src/entt/meta/meta.hpp b/src/entt/meta/meta.hpp
index a1b500e30..ef161470d 100644
--- a/src/entt/meta/meta.hpp
+++ b/src/entt/meta/meta.hpp
@@ -194,12 +194,6 @@ class meta_any {
}
}
- void release() {
- if(storage.owner() && (node.dtor.dtor != nullptr)) {
- node.dtor.dtor(storage.data());
- }
- }
-
meta_any(const meta_any &other, any ref) noexcept
: storage{std::move(ref)},
ctx{other.ctx} {
@@ -333,9 +327,7 @@ public:
vtable{std::exchange(other.vtable, nullptr)} {}
/*! @brief Frees the internal storage, whatever it means. */
- ~meta_any() {
- release();
- }
+ ~meta_any() = default;
/**
* @brief Copy assignment operator.
@@ -344,7 +336,6 @@ public:
*/
meta_any &operator=(const meta_any &other) {
if(this != &other) {
- release();
storage = other.storage;
ctx = other.ctx;
resolve = other.resolve;
@@ -524,7 +515,6 @@ public:
/*! @copydoc any::emplace */
template
void emplace(Args &&...args) {
- release();
storage.emplace(std::forward(args)...);
resolve = internal::resolve>>;
node = resolve(internal::meta_context::from(*ctx));
@@ -539,7 +529,6 @@ public:
/*! @copydoc any::reset */
void reset() {
- release();
storage.reset();
resolve = nullptr;
node = {};
diff --git a/src/entt/meta/node.hpp b/src/entt/meta/node.hpp
index e7237353b..b367b52b9 100644
--- a/src/entt/meta/node.hpp
+++ b/src/entt/meta/node.hpp
@@ -87,10 +87,6 @@ struct meta_ctor_node {
meta_any (*invoke)(const meta_ctx &, meta_any *const){};
};
-struct meta_dtor_node {
- void (*dtor)(void *){};
-};
-
struct meta_data_node {
using size_type = std::size_t;
@@ -148,7 +144,6 @@ struct meta_type_node {
double (*conversion_helper)(void *, const void *){};
meta_any (*from_void)(const meta_ctx &, void *, const void *){};
meta_template_node templ{};
- meta_dtor_node dtor{};
meta_custom_node custom{};
std::shared_ptr details;
};
diff --git a/test/entt/meta/meta_any.cpp b/test/entt/meta/meta_any.cpp
index 29d096398..71a3fd41e 100644
--- a/test/entt/meta/meta_any.cpp
+++ b/test/entt/meta/meta_any.cpp
@@ -39,15 +39,10 @@ struct empty {
empty &operator=(const empty &) = default;
virtual ~empty() {
- ++destructor_counter;
+ ++counter;
}
- static void destroy(empty &) {
- ++destroy_counter;
- }
-
- inline static int destroy_counter = 0; // NOLINT
- inline static int destructor_counter = 0; // NOLINT
+ inline static int counter = 0; // NOLINT
};
struct fat: empty {
@@ -94,13 +89,11 @@ struct MetaAny: ::testing::Test {
using namespace entt::literals;
entt::meta_factory{}
- .type("empty"_hs)
- .dtor();
+ .type("empty"_hs);
entt::meta_factory{}
.type("fat"_hs)
- .base()
- .dtor();
+ .base();
entt::meta_factory{}
.type("clazz"_hs)
@@ -109,8 +102,7 @@ struct MetaAny: ::testing::Test {
.func("func"_hs)
.conv();
- empty::destroy_counter = 0;
- empty::destructor_counter = 0;
+ empty::counter = 0;
}
void TearDown() override {
@@ -1024,8 +1016,7 @@ TEST_F(MetaAny, SBODestruction) {
any = std::move(other);
}
- ASSERT_EQ(empty::destroy_counter, 3);
- ASSERT_EQ(empty::destructor_counter, 6);
+ ASSERT_EQ(empty::counter, 6);
}
TEST_F(MetaAny, NoSBODestruction) {
@@ -1037,8 +1028,7 @@ TEST_F(MetaAny, NoSBODestruction) {
any = std::move(other);
}
- ASSERT_EQ(fat::destroy_counter, 3);
- ASSERT_EQ(empty::destructor_counter, 4);
+ ASSERT_EQ(empty::counter, 4);
}
TEST_F(MetaAny, VoidDestruction) {
diff --git a/test/entt/meta/meta_context.cpp b/test/entt/meta/meta_context.cpp
index 844e7bc18..854ad81d1 100644
--- a/test/entt/meta/meta_context.cpp
+++ b/test/entt/meta/meta_context.cpp
@@ -117,7 +117,6 @@ class MetaContext: public ::testing::Test {
.custom('c')
.base()
.ctor()
- .dtor<&clazz::move_to_bucket>()
.data("value"_hs)
.data<&clazz::value>("rw"_hs)
.func<&clazz::cfunc>("func"_hs);
@@ -336,21 +335,6 @@ TEST_F(MetaContext, MetaConv) {
ASSERT_EQ(local.cast(), value.get_mul());
}
-TEST_F(MetaContext, MetaDtor) {
- auto global = entt::resolve().construct();
- auto local = entt::resolve(ctx()).construct();
-
- ASSERT_EQ(clazz::bucket, bucket_value);
-
- global.reset();
-
- ASSERT_EQ(clazz::bucket, bucket_value);
-
- local.reset();
-
- ASSERT_NE(clazz::bucket, bucket_value);
-}
-
TEST_F(MetaContext, MetaCustom) {
using namespace entt::literals;
diff --git a/test/entt/meta/meta_data.cpp b/test/entt/meta/meta_data.cpp
index 27d295ad3..9f34d0b3d 100644
--- a/test/entt/meta/meta_data.cpp
+++ b/test/entt/meta/meta_data.cpp
@@ -17,12 +17,6 @@
struct base {
virtual ~base() = default;
-
- static void destroy(base &) {
- ++counter;
- }
-
- inline static int counter = 0; // NOLINT
int value{3};
};
@@ -81,13 +75,11 @@ struct MetaData: ::testing::Test {
entt::meta_factory{}
.type("base"_hs)
- .dtor()
.data<&base::value>("value"_hs);
entt::meta_factory{}
.type("derived"_hs)
.base()
- .dtor()
.data<&base::value>("value_from_base"_hs);
entt::meta_factory{}
@@ -120,8 +112,6 @@ struct MetaData: ::testing::Test {
.type("array"_hs)
.data<&array::global>("global"_hs)
.data<&array::local>("local"_hs);
-
- base::counter = 0;
}
void TearDown() override {
@@ -318,10 +308,13 @@ TEST_F(MetaData, SetCast) {
using namespace entt::literals;
clazz instance{};
+ derived other{};
- ASSERT_EQ(base::counter, 0);
- ASSERT_TRUE(entt::resolve().data("base"_hs).set(instance, derived{}));
- ASSERT_EQ(base::counter, 1);
+ other.value = 1;
+
+ ASSERT_EQ(instance.instance.value, 3);
+ ASSERT_TRUE(entt::resolve().data("base"_hs).set(instance, other));
+ ASSERT_EQ(instance.instance.value, 1);
}
TEST_F(MetaData, SetConvert) {
diff --git a/test/entt/meta/meta_factory.cpp b/test/entt/meta/meta_factory.cpp
index b33bcb119..2bce855ba 100644
--- a/test/entt/meta/meta_factory.cpp
+++ b/test/entt/meta/meta_factory.cpp
@@ -49,18 +49,6 @@ private:
int value{};
};
-struct dtor_callback {
- dtor_callback(bool &ref)
- : cb{&ref} {}
-
- static void on_destroy(dtor_callback &instance) {
- *instance.cb = !*instance.cb;
- }
-
-private:
- bool *cb;
-};
-
struct MetaFactory: ::testing::Test {
void TearDown() override {
entt::meta_reset();
@@ -175,22 +163,6 @@ TEST_F(MetaFactory, Ctor) {
ASSERT_EQ(other.cast().get_int(), values[1u]);
}
-TEST_F(MetaFactory, Dtor) {
- bool check = false;
- entt::meta_factory factory{};
- entt::meta_any any{std::in_place_type, check};
-
- any.reset();
-
- ASSERT_FALSE(check);
-
- factory.dtor<&dtor_callback::on_destroy>();
- any.emplace(check);
- any.reset();
-
- ASSERT_TRUE(check);
-}
-
TEST_F(MetaFactory, DataMemberObject) {
using namespace entt::literals;