Struct null_t

Synopsis

#include <src/entt/entity/entity.hpp>

struct null_t

Description

Null object for all entity identifiers.

Methods

operator EntityConverts the null object to identifiers of any type.
operator!=Compares two null objects.
operator==Compares two null objects.

Source

Lines 99-147 in src/entt/entity/entity.hpp.

struct null_t {
    /**
     * @brief Converts the null object to identifiers of any type.
     * @tparam Entity Type of entity identifier.
     * @return The null representation for the given identifier.
     */
    template<typename Entity>
    [[nodiscard]] constexpr operator Entity() const ENTT_NOEXCEPT {
        return Entity{entt_traits<Entity>::entity_mask};
    }

    /**
     * @brief Compares two null objects.
     * @return True in all cases.
     */
    [[nodiscard]] constexpr bool operator==(null_t) const ENTT_NOEXCEPT {
        return true;
    }

    /**
     * @brief Compares two null objects.
     * @return False in all cases.
     */
    [[nodiscard]] constexpr bool operator!=(null_t) const ENTT_NOEXCEPT {
        return false;
    }

    /**
     * @brief Compares a null object and an entity identifier of any type.
     * @tparam Entity Type of entity identifier.
     * @param entity Entity identifier with which to compare.
     * @return False if the two elements differ, true otherwise.
     */
    template<typename Entity>
    [[nodiscard]] constexpr bool operator==(const Entity entity) const ENTT_NOEXCEPT {
        return (to_integral(entity) & entt_traits<Entity>::entity_mask) == to_integral(static_cast<Entity>(*this));
    }

    /**
     * @brief Compares a null object and an entity identifier of any type.
     * @tparam Entity Type of entity identifier.
     * @param entity Entity identifier with which to compare.
     * @return True if the two elements differ, false otherwise.
     */
    template<typename Entity>
    [[nodiscard]] constexpr bool operator!=(const Entity entity) const ENTT_NOEXCEPT {
        return !(entity == *this);
    }
};





Add Discussion

Log in to comment