|
@@ -806,12 +806,12 @@ public:
|
|
|
*/
|
|
*/
|
|
|
template<typename Type, typename... Args>
|
|
template<typename Type, typename... Args>
|
|
|
decltype(auto) emplace_or_replace(const entity_type entt, Args &&...args) {
|
|
decltype(auto) emplace_or_replace(const entity_type entt, Args &&...args) {
|
|
|
- ENTT_ASSERT(valid(entt), "Invalid entity");
|
|
|
|
|
- auto &cpool = assure<Type>();
|
|
|
|
|
-
|
|
|
|
|
- return cpool.contains(entt)
|
|
|
|
|
- ? cpool.patch(entt, [&args...](auto &...curr) { ((curr = Type{std::forward<Args>(args)...}), ...); })
|
|
|
|
|
- : cpool.emplace(entt, std::forward<Args>(args)...);
|
|
|
|
|
|
|
+ if (auto& cpool = assure<Type>(); cpool.contains(entt)) {
|
|
|
|
|
+ return cpool.patch(entt, [&args...](auto &...curr) { ((curr = Type{std::forward<Args>(args)...}), ...); });
|
|
|
|
|
+ } else {
|
|
|
|
|
+ ENTT_ASSERT(valid(entt), "Invalid entity");
|
|
|
|
|
+ return cpool.emplace(entt, std::forward<Args>(args)...);
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|