any: added ::reset
This commit is contained in:
@@ -266,6 +266,11 @@ public:
|
||||
*this = any{std::in_place_type<Type>, std::forward<Args>(args)...};
|
||||
}
|
||||
|
||||
/*! @brief Destroys contained object */
|
||||
void reset() {
|
||||
emplace<void>();
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Returns false if a wrapper is empty, true otherwise.
|
||||
* @return False if the wrapper is empty, true otherwise.
|
||||
|
||||
@@ -462,6 +462,18 @@ TEST(Any, EmplaceVoid) {
|
||||
ASSERT_FALSE(any.type());
|
||||
}
|
||||
|
||||
TEST(Any, Reset) {
|
||||
entt::any any{42};
|
||||
|
||||
ASSERT_TRUE(any);
|
||||
ASSERT_EQ(any.type(), entt::type_id<int>());
|
||||
|
||||
any.reset();
|
||||
|
||||
ASSERT_FALSE(any);
|
||||
ASSERT_EQ(any.type(), entt::type_info{});
|
||||
}
|
||||
|
||||
TEST(Any, SBOSwap) {
|
||||
entt::any lhs{'c'};
|
||||
entt::any rhs{42};
|
||||
|
||||
Reference in New Issue
Block a user