Function first


#include <include/flecs/addons/cpp/mixins/id/decl.hpp>

flecs::entity first() const


Get first element from a pair. If the id is not a pair, this operation will fail. When the id has a world, the operation will ensure that the returned id has the correct generation count.

Mentioned in


Lines 14-23 in include/flecs/addons/cpp/mixins/id/impl.hpp. Line 94 in include/flecs/addons/cpp/mixins/id/decl.hpp.

inline flecs::entity id::first() const {
    ecs_assert(is_pair(), ECS_INVALID_OPERATION, NULL);

    flecs::entity_t e = ECS_PAIR_FIRST(m_id);
    if (m_world) {
        return flecs::entity(m_world, ecs_get_alive(m_world, e));
    } else {
        return flecs::entity(e);