Previously, calls to the methods assign<C>(...), emit<E>(...), and add<S>(...)
would fail if constructor arguments relied upon move semantics.
*/
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) ...)));
}
/**
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>
*/
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));
}
#include <unordered_map>
+#include <utility>
#include <stdint.h>
#include <cassert>
#include "entityx/config.h"
*/
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;
}