diff options
author | Alec Thomas <alec@swapoff.org> | 2013-12-25 09:11:52 -0800 |
---|---|---|
committer | Alec Thomas <alec@swapoff.org> | 2013-12-25 09:11:52 -0800 |
commit | dd01f4db65d8be9dc7fb8b8d698548874cfb8a39 (patch) | |
tree | 0eff658a29d749200f67321ff9585cb8e9c89c14 | |
parent | 4a97a96a01b5acb75709587ac8ac5bf3d5d693ca (diff) | |
parent | cc783cfc82ab99d90070193da71c4970bc08a96e (diff) |
Merge pull request #21 from scott-linder/master
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(); |