meta: operator==/!= for meta_func
This commit is contained in:
@@ -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>
|
||||
|
||||
@@ -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());
|
||||
|
||||
Reference in New Issue
Block a user