From ed335a37b5f2795c4b51baed1b29eb94dc01de09 Mon Sep 17 00:00:00 2001 From: Peter Thorson Date: Sun, 31 Jan 2016 11:07:36 -0500 Subject: [PATCH] Replace deprecated use of auto_ptr when unique_ptr is available --- changelog.md | 2 ++ websocketpp/common/memory.hpp | 1 + websocketpp/transport/asio/endpoint.hpp | 9 ++++++++- 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/changelog.md b/changelog.md index 0d4e464..e2da93d 100644 --- a/changelog.md +++ b/changelog.md @@ -46,6 +46,8 @@ HEAD Thank you giachi and Bastien Brunnenstein for reporting. #491 - Compatibility: Fixes a number of build & config issues on Visual Studio 2015 - Compatibility: Removes non-standards compliant masking behavior. #395, #469 +- Compatibility: Replace deprecated use of auto_ptr on systems where unique_ptr + is available. 0.6.0 - MINOR BREAKING TRANSPORT POLICY CHANGE: Custom transport policies will now be diff --git a/websocketpp/common/memory.hpp b/websocketpp/common/memory.hpp index 4187e1a..581aa55 100644 --- a/websocketpp/common/memory.hpp +++ b/websocketpp/common/memory.hpp @@ -69,6 +69,7 @@ namespace lib { using std::enable_shared_from_this; using std::static_pointer_cast; using std::make_shared; + using std::unique_ptr; typedef std::unique_ptr unique_ptr_uchar_array; #else diff --git a/websocketpp/transport/asio/endpoint.hpp b/websocketpp/transport/asio/endpoint.hpp index d0af215..20d1ce8 100644 --- a/websocketpp/transport/asio/endpoint.hpp +++ b/websocketpp/transport/asio/endpoint.hpp @@ -218,8 +218,15 @@ public: * @param ec Set to indicate what error occurred, if any. */ void init_asio(lib::error_code & ec) { - // Use a smart pointer until the call is successful and ownership has successfully been taken + // Use a smart pointer until the call is successful and ownership has + // successfully been taken. Use unique_ptr when available. + // TODO: remove the use of auto_ptr when C++98/03 support is no longer + // necessary. +#ifdef _WEBSOCKETPP_CPP11_MEMORY_ + lib::unique_ptr service(new lib::asio::io_service()); +#else lib::auto_ptr service(new lib::asio::io_service()); +#endif init_asio(service.get(), ec); if( !ec ) service.release(); // Call was successful, transfer ownership m_external_io_service = false;