From 719de94821460d918fa78a39fbd1162d4b58baeb Mon Sep 17 00:00:00 2001 From: orignal Date: Wed, 11 Jan 2017 19:45:04 -0500 Subject: [PATCH] acquire unique_ptr --- util.h | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/util.h b/util.h index 84299d25..3b30919e 100644 --- a/util.h +++ b/util.h @@ -1,9 +1,9 @@ #ifndef UTIL_H #define UTIL_H -#include #include -#include +#include +#include #include #ifdef ANDROID @@ -45,7 +45,7 @@ namespace util } template - T * Acquire (TArgs... args) + T * Acquire (TArgs&&... args) { if (!m_Head) return new T(args...); else @@ -64,6 +64,13 @@ namespace util m_Head = t; } + template + std::unique_ptr > AcquireUnique (TArgs&&... args) + { + return std::unique_ptr >(Acquire (args...), + std::bind (&MemoryPool::Release, this, std::placeholders::_1)); + } + private: T * m_Head;