Function emplace


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

template <typename T, typename ... Args>
Self & emplace(Args &&... args)


Emplace component. Emplace constructs a component in the storage, which prevents calling the destructor on the value passed into the function.

Emplace attempts the following signatures to construct the component: T{Args...} T{flecs::entity, Args...}

If the second signature matches, emplace will pass in the current entity as argument to the constructor, which is useful if the component needs to be aware of the entity to which it has been added.

Emplace may only be called for components that have not yet been added to the entity.

Template Parameters

T - the component to emplace


args - The arguments to pass to the constructor of T


Lines 739-744 in include/flecs/addons/cpp/mixins/entity/builder.hpp.

template <typename T, typename ... Args>
Self& emplace(Args&&... args) {
    flecs::emplace<T>(this->m_world, this->m_id, 
    return to_base();