Function with

Summary

#include <include/flecs/addons/cpp/mixins/entity/builder.hpp>

(1) template <typename Func>
    Self & with(const Func &func)

(2) template <typename First, typename Func>
    Self & with(const Func &func)

(3) template <typename Func>
    Self & with(entity_t first, const Func &func)

Function overload

Synopsis

#include <include/flecs/addons/cpp/mixins/entity/builder.hpp>

template <typename Func>
Self & with(const Func &func)

Description

Entities created in function will have the current entity.

Parameters

func - The function to call.

Source

Lines 750-756 in include/flecs/addons/cpp/mixins/entity/builder.hpp.

template <typename Func>
Self& with(const Func& func) {
    ecs_id_t prev = ecs_set_with(this->m_world, this->m_id);
    func();
    ecs_set_with(this->m_world, prev);
    return to_base();
}

Synopsis

#include <include/flecs/addons/cpp/mixins/entity/builder.hpp>

template <typename First, typename Func>
Self & with(const Func &func)

Description

Entities created in function will have (First, this) This operation is thread safe.

Template Parameters

First - The first element of the pair

Parameters

func - The function to call.

Source

Lines 764-768 in include/flecs/addons/cpp/mixins/entity/builder.hpp.

template <typename First, typename Func>
Self& with(const Func& func) {
    with(_::cpp_type<First>::id(this->m_world), func);
    return to_base();
}

Synopsis

#include <include/flecs/addons/cpp/mixins/entity/builder.hpp>

template <typename Func>
Self & with(entity_t first, const Func &func)

Description

Entities created in function will have (first, this)

Parameters

first - The first element of the pair.

func - The function to call.

Source

Lines 775-782 in include/flecs/addons/cpp/mixins/entity/builder.hpp.

template <typename Func>
Self& with(entity_t first, const Func& func) {
    ecs_id_t prev = ecs_set_with(this->m_world, 
        ecs_pair(first, this->m_id));
    func();
    ecs_set_with(this->m_world, prev);
    return to_base();
}