diff options
author | scott-linder <scott.b.linder@wmich.edu> | 2013-12-24 22:42:03 -0500 |
---|---|---|
committer | scott-linder <scott.b.linder@wmich.edu> | 2013-12-24 22:42:03 -0500 |
commit | cc783cfc82ab99d90070193da71c4970bc08a96e (patch) | |
tree | 0eff658a29d749200f67321ff9585cb8e9c89c14 | |
parent | 4a97a96a01b5acb75709587ac8ac5bf3d5d693ca (diff) |
Added entityx::make_ptr to mirror std::make_shared
-rw-r--r-- | entityx/config.h.in | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/entityx/config.h.in b/entityx/config.h.in index 2e6f000..940d4d1 100644 --- a/entityx/config.h.in +++ b/entityx/config.h.in @@ -17,6 +17,8 @@ static const uint64_t MAX_COMPONENTS = ENTITYX_MAX_COMPONENTS; // Which shared_ptr implementation should we use? #include <memory> +// for std::forward() +#include <utility> namespace entityx { @@ -35,6 +37,11 @@ using enable_shared_from_this = std::enable_shared_from_this<T>; namespace entityx { +template <typename T, typename... Args> +ptr<T> make_ptr(Args&&... args) { + return ptr<T>(::new T(std::forward<Args>(args)...)); +} + template <typename T> bool operator == (const weak_ptr<T> &a, const weak_ptr<T> &b) { return a.lock() == b.lock(); |