meta: added meta_any::reset

This commit is contained in:
Michele Caini
2021-01-23 18:19:11 +01:00
parent 5149d1395e
commit 6c804b5ca2
2 changed files with 17 additions and 0 deletions

View File

@@ -639,6 +639,11 @@ public:
*this = meta_any{std::in_place_type<Type>, std::forward<Args>(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.

View File

@@ -462,6 +462,18 @@ TEST_F(MetaAny, EmplaceVoid) {
ASSERT_EQ(any, (entt::meta_any{std::in_place_type<void>}));
}
TEST_F(MetaAny, Reset) {
entt::meta_any any{42};
ASSERT_TRUE(any);
ASSERT_EQ(any.type(), entt::resolve<int>());
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};