meta: operator==/!= for meta_func

This commit is contained in:
Michele Caini
2023-04-06 12:40:42 +02:00
parent 3a4672793d
commit 89ab5c328a
2 changed files with 21 additions and 0 deletions

View File

@@ -1053,11 +1053,26 @@ struct meta_func {
return (node != nullptr);
}
/*! @copydoc meta_prop::operator== */
[[nodiscard]] bool operator==(const meta_func &other) const noexcept {
return (ctx == other.ctx && node == other.node);
}
private:
const internal::meta_func_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_func &lhs, const meta_func &rhs) noexcept {
return !(lhs == rhs);
}
/*! @brief Opaque wrapper for types. */
class meta_type {
template<typename Func>

View File

@@ -170,6 +170,12 @@ TEST_F(MetaFunc, Functionalities) {
func_t instance{};
ASSERT_TRUE(func);
ASSERT_EQ(func, func);
ASSERT_NE(func, entt::meta_func{});
ASSERT_FALSE(func != func);
ASSERT_TRUE(func == func);
ASSERT_EQ(func.arity(), 2u);
ASSERT_FALSE(func.is_const());
ASSERT_FALSE(func.is_static());