From cf018ff74c685f82cb3c559839ad12d3f337a551 Mon Sep 17 00:00:00 2001 From: Michele Caini Date: Sun, 18 Oct 2020 23:37:18 +0200 Subject: [PATCH] entity: updated operator==/operator!= (close #573) --- src/entt/entity/entity.hpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/entt/entity/entity.hpp b/src/entt/entity/entity.hpp index 03b2a9808..d475524ce 100644 --- a/src/entt/entity/entity.hpp +++ b/src/entt/entity/entity.hpp @@ -111,7 +111,7 @@ struct null_t { * @brief Compares two null objects. * @return True in all cases. */ - [[nodiscard]] constexpr bool operator==(null_t) const ENTT_NOEXCEPT { + [[nodiscard]] constexpr bool operator==(const null_t &) const ENTT_NOEXCEPT { return true; } @@ -119,7 +119,7 @@ struct null_t { * @brief Compares two null objects. * @return False in all cases. */ - [[nodiscard]] constexpr bool operator!=(null_t) const ENTT_NOEXCEPT { + [[nodiscard]] constexpr bool operator!=(const null_t &) const ENTT_NOEXCEPT { return false; } @@ -130,7 +130,7 @@ struct null_t { * @return False if the two elements differ, true otherwise. */ template - [[nodiscard]] constexpr bool operator==(const Entity entity) const ENTT_NOEXCEPT { + [[nodiscard]] constexpr bool operator==(const Entity &entity) const ENTT_NOEXCEPT { return (to_integral(entity) & entt_traits::entity_mask) == to_integral(static_cast(*this)); } @@ -141,7 +141,7 @@ struct null_t { * @return True if the two elements differ, false otherwise. */ template - [[nodiscard]] constexpr bool operator!=(const Entity entity) const ENTT_NOEXCEPT { + [[nodiscard]] constexpr bool operator!=(const Entity &entity) const ENTT_NOEXCEPT { return !(entity == *this); } }; @@ -155,7 +155,7 @@ struct null_t { * @return False if the two elements differ, true otherwise. */ template -[[nodiscard]] constexpr bool operator==(const Entity entity, null_t other) ENTT_NOEXCEPT { +[[nodiscard]] constexpr bool operator==(const Entity &entity, const null_t &other) ENTT_NOEXCEPT { return other.operator==(entity); } @@ -168,7 +168,7 @@ template * @return True if the two elements differ, false otherwise. */ template -[[nodiscard]] constexpr bool operator!=(const Entity entity, null_t other) ENTT_NOEXCEPT { +[[nodiscard]] constexpr bool operator!=(const Entity &entity, const null_t &other) ENTT_NOEXCEPT { return !(other == entity); }