azure-core
Loading...
Searching...
No Matches
unique_handle.hpp
1// Copyright (c) Microsoft Corporation.
2// Licensed under the MIT License.
3#pragma once
4#include <memory>
5
6namespace Azure { namespace Core {
7 namespace _detail {
21 // *** Given just T, map it to the corresponding FreeFunc
22 template <typename T> struct UniqueHandleHelper;
23 } // namespace _detail
24
25 namespace _internal {
55 template <typename T, void (&Deleter)(T*)> struct UniqueHandleDeleter
56 {
57 void operator()(T* obj) { Deleter(obj); }
58 };
59
63 template <typename T, void (&FreeFunc)(T*)>
64 using BasicUniqueHandle = std::unique_ptr<T, UniqueHandleDeleter<T, FreeFunc>>;
65
66 // *** Now users can say UniqueHandle<T> if they want:
67 template <typename T, template <typename> class U = _detail::UniqueHandleHelper>
68 using UniqueHandle = typename U<T>::type;
69 } // namespace _internal
70
71 namespace _detail {
72 void FreeWinHttpHandleImpl(void* obj);
73
81 template <> struct UniqueHandleHelper<void*>
82 {
83 static void FreeWinHttpHandle(void* obj) { FreeWinHttpHandleImpl(obj); }
84
85 using type = _internal::BasicUniqueHandle<void, FreeWinHttpHandle>;
86 };
87 } // namespace _detail
88}} // namespace Azure::Core
Compute the hash value for the input binary data, using SHA256, SHA384 and SHA512.
Definition azure_assert.hpp:57