From 180657e756fefbe5d601c64b860ee470217b4956 Mon Sep 17 00:00:00 2001 From: Alex Zolotarev Date: Wed, 6 Aug 2014 22:53:58 +0300 Subject: [PATCH] [c++11] Enhanced ptr classes --- std/shared_ptr.hpp | 9 +++++++++ std/unique_ptr.hpp | 13 +++++++++++++ std/weak_ptr.hpp | 11 ++++++++++- 3 files changed, 32 insertions(+), 1 deletion(-) create mode 100644 std/unique_ptr.hpp diff --git a/std/shared_ptr.hpp b/std/shared_ptr.hpp index 23b69a1921..9d08b751a0 100644 --- a/std/shared_ptr.hpp +++ b/std/shared_ptr.hpp @@ -5,11 +5,20 @@ #undef new #endif +#if __cplusplus > 199711L + +#include +using std::shared_ptr; + +#else + #include using boost::shared_ptr; using boost::static_pointer_cast; +#endif + template inline shared_ptr make_shared_ptr(T * t) { diff --git a/std/unique_ptr.hpp b/std/unique_ptr.hpp new file mode 100644 index 0000000000..e0f9f2e16b --- /dev/null +++ b/std/unique_ptr.hpp @@ -0,0 +1,13 @@ +#pragma once +#include "common_defines.hpp" + +#ifdef new +#undef new +#endif + +#include +using std::unique_ptr; + +#ifdef DEBUG_NEW +#define new DEBUG_NEW +#endif diff --git a/std/weak_ptr.hpp b/std/weak_ptr.hpp index 7539859a72..ac9f183e07 100644 --- a/std/weak_ptr.hpp +++ b/std/weak_ptr.hpp @@ -5,9 +5,18 @@ #undef new #endif +#if __cplusplus > 199711L + +#include +using std::weak_ptr; + +#else + #include using boost::weak_ptr; +#endif + #ifdef DEBUG_NEW #define new DEBUG_NEW -#endif \ No newline at end of file +#endif