From 4ed555b422f8fccb10cfc080847434fb131f8267 Mon Sep 17 00:00:00 2001 From: Sebastian Messmer Date: Mon, 17 Sep 2018 20:12:23 -0700 Subject: [PATCH] Use unique_ref instead of unique_ptr --- src/cpp-utils/network/WinHttpClient.cpp | 4 ++-- src/cpp-utils/network/WinHttpClient.h | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/cpp-utils/network/WinHttpClient.cpp b/src/cpp-utils/network/WinHttpClient.cpp index 995c3f0c..4ee9c47d 100644 --- a/src/cpp-utils/network/WinHttpClient.cpp +++ b/src/cpp-utils/network/WinHttpClient.cpp @@ -211,13 +211,13 @@ namespace cpputils { }; namespace { - std::unique_ptr create_session() { + cpputils::unique_ref create_session() { HttpHandleRAII session_handle = WinHttpOpen(L"cpputils::HttpClient", WINHTTP_ACCESS_TYPE_AUTOMATIC_PROXY, WINHTTP_NO_PROXY_NAME, WINHTTP_NO_PROXY_BYPASS, 0); if(nullptr == session_handle.handle) { throw std::runtime_error("Error calling WinHttpOpen. Error code: " + std::to_string(GetLastError())); } - return std::make_unique(std::move(session_handle)); + return cpputils::make_unique<_refWinHttpSession>(std::move(session_handle)); } } diff --git a/src/cpp-utils/network/WinHttpClient.h b/src/cpp-utils/network/WinHttpClient.h index f84517bd..8ef55b2e 100644 --- a/src/cpp-utils/network/WinHttpClient.h +++ b/src/cpp-utils/network/WinHttpClient.h @@ -6,6 +6,7 @@ #include "HttpClient.h" #include "../macros.h" +#include "../pointer/unique_ref.h" namespace cpputils { @@ -19,7 +20,7 @@ namespace cpputils { std::string get(const std::string &url, boost::optional timeoutMsec = boost::none) override; private: - std::unique_ptr session_; + unique_ref session_; DISALLOW_COPY_AND_ASSIGN(WinHttpClient); };