diff options
author | scott-linder <scott.b.linder@wmich.edu> | 2013-12-30 19:33:17 -0500 |
---|---|---|
committer | scott-linder <scott.b.linder@wmich.edu> | 2013-12-30 19:51:07 -0500 |
commit | 9d5a03233f4b9495b8698ed8e4bad3d246cbbf13 (patch) | |
tree | ac22e6f344bee0c5e877f2e5eea70b1b4a1aa7b6 | |
parent | cc783cfc82ab99d90070193da71c4970bc08a96e (diff) |
Added std::forward in order to respect move semantics in some methods.
Previously, calls to the methods assign<C>(...), emit<E>(...), and add<S>(...)
would fail if constructor arguments relied upon move semantics.
-rw-r--r-- | entityx/Entity.h | 4 | ||||
-rw-r--r-- | entityx/Event.h | 2 | ||||
-rw-r--r-- | entityx/System.h | 3 |
3 files changed, 5 insertions, 4 deletions
diff --git a/entityx/Entity.h b/entityx/Entity.h index 9577375..1758c3f 100644 --- a/entityx/Entity.h +++ b/entityx/Entity.h @@ -474,7 +474,7 @@ class EntityManager : entityx::help::NonCopyable, public enable_shared_from_this */ template <typename C, typename ... Args> ptr<C> assign(Entity::Id entity, Args && ... args) { - return assign<C>(entity, ptr<C>(new C(args ...))); + return assign<C>(entity, ptr<C>(new C(std::forward<Args>(args) ...))); } /** @@ -630,7 +630,7 @@ ptr<C> Entity::assign(ptr<C> component) { template <typename C, typename ... Args> ptr<C> Entity::assign(Args && ... args) { assert(valid()); - return manager_.lock()->assign<C>(id_, args ...); + return manager_.lock()->assign<C>(id_, std::forward<Args>(args) ...); } template <typename C> diff --git a/entityx/Event.h b/entityx/Event.h index e60e7d7..dac1bb4 100644 --- a/entityx/Event.h +++ b/entityx/Event.h @@ -160,7 +160,7 @@ class EventManager : entityx::help::NonCopyable { */ template <typename E, typename ... Args> void emit(Args && ... args) { - E event(args ...); + E event(std::forward<Args>(args) ...); auto sig = signal_for(E::family()); sig->emit(static_cast<BaseEvent*>(&event)); } diff --git a/entityx/System.h b/entityx/System.h index 132b8b9..9c0b2ec 100644 --- a/entityx/System.h +++ b/entityx/System.h @@ -12,6 +12,7 @@ #include <unordered_map> +#include <utility> #include <stdint.h> #include <cassert> #include "entityx/config.h" @@ -108,7 +109,7 @@ class SystemManager : entityx::help::NonCopyable, public enable_shared_from_this */ template <typename S, typename ... Args> ptr<S> add(Args && ... args) { - ptr<S> s(new S(args ...)); + ptr<S> s(new S(std::forward<Args>(args) ...)); add(s); return s; } |