slightly improved registry::replace (thanks to ColinH for pointing it out)

This commit is contained in:
Michele Caini
2019-04-29 23:19:09 +02:00
parent bf63b15e07
commit 77ea28bef2
2 changed files with 2 additions and 3 deletions

View File

@@ -7,6 +7,7 @@ skypjack
BenediktConze
bjadamson
ceeac
ColinH
corystegel
Croydon
dbacchet

View File

@@ -98,9 +98,7 @@ class basic_registry {
Component & replace(const Entity entt, Args &&... args) {
Component component{std::forward<Args>(args)...};
on_replace.publish(*owner, entt, component);
auto &other = sparse_set<Entity, Component>::get(entt);
std::swap(other, component);
return other;
return (sparse_set<Entity, Component>::get(entt) = std::move(component));
}
};