qxLib
unique_ref.inl
Go to the documentation of this file.
1 /**
2 
3  @file unique_ref.inl
4  @author Khrapov
5  @date 25.05.2025
6  @copyright © Nick Khrapov, 2025. All right reserved.
7 
8 **/
9 
10 namespace qx
11 {
12 
13 template<class T, class... constructor_args_t>
14 unique_ref<T> make_unique_ref(constructor_args_t&&... args)
15 {
16  return unique_ref<T>(
18  std::make_unique<T>(std::forward<constructor_args_t>(args)...));
19 }
20 
21 template<class T, class deleter_t, class... constructor_args_t>
22 unique_ref<T, deleter_t> make_unique_ref_with_deleter(deleter_t deleter, constructor_args_t&&... args)
23 {
26  std::unique_ptr<T, deleter_t>(new T(std::forward<constructor_args_t>(args)...), std::move(deleter)));
27 }
28 
29 namespace details
30 {
31 
32 template<class T, class... args_t>
33 void smart_ptr_ref_adapter<std::unique_ptr, T, args_t...>::reset(smart_ptr_ref_adapter other) noexcept
34 {
35  *this = std::move(other);
36 }
37 
38 template<class T, class... args_t>
39 template<class... constructor_args_t>
40 smart_ptr_ref_adapter<std::unique_ptr, T, args_t...>::smart_ptr_ref_adapter(private_token, constructor_args_t&&... args)
41  : super(std::forward<constructor_args_t>(args)...)
42 {
43 }
44 
45 } // namespace details
46 
47 } // namespace qx
unique_ref< T, deleter_t > make_unique_ref_with_deleter(deleter_t deleter, constructor_args_t &&... args)
Make a unique ref with a custom deleter.
Definition: unique_ref.inl:22
unique_ref< T > make_unique_ref(constructor_args_t &&... args)
Make a unique ref (same as std::make_unique but for qx::unique_ref)
Definition: unique_ref.inl:14