meta: operator==/!= for meta_handle (see #1002)
This commit is contained in:
@@ -722,6 +722,16 @@ struct meta_handle {
|
||||
return static_cast<bool>(any);
|
||||
}
|
||||
|
||||
/*! @copydoc meta_any::operator== */
|
||||
[[nodiscard]] bool operator==(const meta_handle &other) const noexcept {
|
||||
return (any == other.any);
|
||||
}
|
||||
|
||||
/*! @copydoc meta_any::operator!= */
|
||||
[[nodiscard]] bool operator!=(const meta_handle &other) const noexcept {
|
||||
return !(*this == other);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Access operator for accessing the contained opaque object.
|
||||
* @return A wrapper that shares a reference to an unmanaged object.
|
||||
|
||||
@@ -44,12 +44,22 @@ TEST_F(MetaHandle, Functionalities) {
|
||||
ASSERT_FALSE(handle);
|
||||
ASSERT_FALSE(chandle);
|
||||
|
||||
ASSERT_EQ(handle, chandle);
|
||||
ASSERT_EQ(handle, entt::meta_handle{});
|
||||
ASSERT_FALSE(handle != handle);
|
||||
ASSERT_TRUE(handle == handle);
|
||||
|
||||
handle = entt::meta_handle{instance};
|
||||
chandle = entt::meta_handle{std::as_const(instance)};
|
||||
|
||||
ASSERT_TRUE(handle);
|
||||
ASSERT_TRUE(chandle);
|
||||
|
||||
ASSERT_EQ(handle, chandle);
|
||||
ASSERT_NE(handle, entt::meta_handle{});
|
||||
ASSERT_FALSE(handle != handle);
|
||||
ASSERT_TRUE(handle == handle);
|
||||
|
||||
ASSERT_TRUE(handle->invoke("incr"_hs));
|
||||
ASSERT_FALSE(chandle->invoke("incr"_hs));
|
||||
ASSERT_FALSE(std::as_const(handle)->invoke("incr"_hs));
|
||||
|
||||
Reference in New Issue
Block a user