diff --git a/src/entt/meta/meta.hpp b/src/entt/meta/meta.hpp index 1b315493c..91bdd9b0f 100644 --- a/src/entt/meta/meta.hpp +++ b/src/entt/meta/meta.hpp @@ -639,6 +639,11 @@ public: *this = meta_any{std::in_place_type, std::forward(args)...}; } + /*! @brief Destroys contained object */ + void reset() { + *this = meta_any{}; + } + /** * @brief Returns a sequence container proxy. * @return A sequence container proxy for the underlying object. diff --git a/test/entt/meta/meta_any.cpp b/test/entt/meta/meta_any.cpp index b538eac38..458d5db58 100644 --- a/test/entt/meta/meta_any.cpp +++ b/test/entt/meta/meta_any.cpp @@ -462,6 +462,18 @@ TEST_F(MetaAny, EmplaceVoid) { ASSERT_EQ(any, (entt::meta_any{std::in_place_type})); } +TEST_F(MetaAny, Reset) { + entt::meta_any any{42}; + + ASSERT_TRUE(any); + ASSERT_EQ(any.type(), entt::resolve()); + + any.reset(); + + ASSERT_FALSE(any); + ASSERT_EQ(any.type(), entt::meta_type{}); +} + TEST_F(MetaAny, SBOSwap) { entt::meta_any lhs{'c'}; entt::meta_any rhs{42};