Skip to content

Commit 4ed555b

Browse files
committed
Use unique_ref instead of unique_ptr
1 parent a537979 commit 4ed555b

2 files changed

Lines changed: 4 additions & 3 deletions

File tree

src/cpp-utils/network/WinHttpClient.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -211,13 +211,13 @@ namespace cpputils {
211211
};
212212

213213
namespace {
214-
std::unique_ptr<WinHttpSession> create_session() {
214+
cpputils::unique_ref<WinHttpSession> create_session() {
215215
HttpHandleRAII session_handle = WinHttpOpen(L"cpputils::HttpClient", WINHTTP_ACCESS_TYPE_AUTOMATIC_PROXY, WINHTTP_NO_PROXY_NAME, WINHTTP_NO_PROXY_BYPASS, 0);
216216
if(nullptr == session_handle.handle) {
217217
throw std::runtime_error("Error calling WinHttpOpen. Error code: " + std::to_string(GetLastError()));
218218
}
219219

220-
return std::make_unique<WinHttpSession>(std::move(session_handle));
220+
return cpputils::make_unique<_refWinHttpSession>(std::move(session_handle));
221221
}
222222
}
223223

src/cpp-utils/network/WinHttpClient.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
#include "HttpClient.h"
88
#include "../macros.h"
9+
#include "../pointer/unique_ref.h"
910

1011
namespace cpputils {
1112

@@ -19,7 +20,7 @@ namespace cpputils {
1920
std::string get(const std::string &url, boost::optional<long> timeoutMsec = boost::none) override;
2021

2122
private:
22-
std::unique_ptr<WinHttpSession> session_;
23+
unique_ref<WinHttpSession> session_;
2324

2425
DISALLOW_COPY_AND_ASSIGN(WinHttpClient);
2526
};

0 commit comments

Comments
 (0)