|
|
@@ -737,43 +737,11 @@ public:
|
|
|
* @param func Valid function objects.
|
|
|
*/
|
|
|
template<typename Component, typename... Func>
|
|
|
- auto replace(const entity_type entity, Func &&... func)
|
|
|
- -> decltype(std::enable_if_t<sizeof...(Func) != 0>(), (func(std::declval<Component &>()), ...), void()) {
|
|
|
+ void replace(const entity_type entity, Func &&... func) {
|
|
|
ENTT_ASSERT(valid(entity));
|
|
|
assure<Component>().replace(*this, entity, std::forward<Func>(func)...);
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * @copybrief replace
|
|
|
- *
|
|
|
- * A new instance of the given component is created and initialized with the
|
|
|
- * arguments provided (the component must have a proper constructor or be of
|
|
|
- * aggregate type). Then the component is assigned to the given entity.
|
|
|
- *
|
|
|
- * @warning
|
|
|
- * Attempting to use an invalid entity or to replace a component of an
|
|
|
- * entity that doesn't own it results in undefined behavior.<br/>
|
|
|
- * An assertion will abort the execution at runtime in debug mode in case of
|
|
|
- * invalid entity or if the entity doesn't own an instance of the given
|
|
|
- * component.
|
|
|
- *
|
|
|
- * @tparam Component Type of component to replace.
|
|
|
- * @tparam Args Types of arguments to use to construct the component.
|
|
|
- * @param entity A valid entity identifier.
|
|
|
- * @param args Parameters to use to initialize the component.
|
|
|
- * @return A reference to the component being replaced.
|
|
|
- */
|
|
|
- template<typename Component, typename... Args>
|
|
|
- [[deprecated("use in-place replace instead")]]
|
|
|
- auto replace(const entity_type entity, Args &&... args)
|
|
|
- -> decltype(Component{std::forward<Args>(args)...}, assure<Component>().get(entity)) {
|
|
|
- replace<Component>(entity, [args = std::forward_as_tuple(std::forward<Args>(args)...)](auto &&component) {
|
|
|
- component = std::make_from_tuple<Component>(std::move(args));
|
|
|
- });
|
|
|
-
|
|
|
- return assure<Component>().get(entity);
|
|
|
- }
|
|
|
-
|
|
|
/**
|
|
|
* @brief Removes the given components from an entity.
|
|
|
*
|