Function get_or_emplace

Synopsis

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

template <typename Component, typename... Args>
decltype(auto) get_or_emplace(Args &&... args) const

Description

Returns a reference to the given component for a handle.

See
basic_registry::get_or_emplace
Template Parameters

Component - Type of component to get.

Args - Types of arguments to use to construct the component.

Parameters

args - Parameters to use to initialize the component.

Return
Reference to the component owned by the handle.

Source

Lines 247-251 in src/entt/entity/handle.hpp.

template<typename Component, typename... Args>
[[nodiscard]] decltype(auto) get_or_emplace(Args &&... args) const {
    static_assert(((sizeof...(Type) == 0) || ... || std::is_same_v<Component, Type>));
    return reg->template get_or_emplace<Component>(entt, std::forward<Args>(args)...);
}





Add Discussion

Log in to comment