meta: operator==/!= for meta_data (close #1002)
This commit is contained in:
@@ -894,11 +894,26 @@ struct meta_data {
|
||||
return (node != nullptr);
|
||||
}
|
||||
|
||||
/*! @copydoc meta_prop::operator== */
|
||||
[[nodiscard]] bool operator==(const meta_data &other) const noexcept {
|
||||
return (ctx == other.ctx && node == other.node);
|
||||
}
|
||||
|
||||
private:
|
||||
const internal::meta_data_node *node;
|
||||
const meta_ctx *ctx;
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Checks if two objects refer to the same type.
|
||||
* @param lhs An object, either valid or not.
|
||||
* @param rhs An object, either valid or not.
|
||||
* @return False if the objects refer to the same node, true otherwise.
|
||||
*/
|
||||
[[nodiscard]] inline bool operator!=(const meta_data &lhs, const meta_data &rhs) noexcept {
|
||||
return !(lhs == rhs);
|
||||
}
|
||||
|
||||
/*! @brief Opaque wrapper for member functions. */
|
||||
struct meta_func {
|
||||
/*! @brief Unsigned integer type. */
|
||||
|
||||
@@ -164,6 +164,12 @@ TEST_F(MetaData, Functionalities) {
|
||||
clazz_t instance{};
|
||||
|
||||
ASSERT_TRUE(data);
|
||||
|
||||
ASSERT_EQ(data, data);
|
||||
ASSERT_NE(data, entt::meta_data{});
|
||||
ASSERT_FALSE(data != data);
|
||||
ASSERT_TRUE(data == data);
|
||||
|
||||
ASSERT_EQ(data.arity(), 1u);
|
||||
ASSERT_EQ(data.type(), entt::resolve<int>());
|
||||
ASSERT_EQ(data.arg(0u), entt::resolve<int>());
|
||||
|
||||
Reference in New Issue
Block a user