qxLib
shared_ref.inl
Go to the documentation of this file.
1 /**
2 
3  @file shared_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 shared_ref<T> make_shared_ref(constructor_args_t&&... args)
15 {
16  return shared_ref<T>(
18  std::make_shared<T>(std::forward<constructor_args_t>(args)...));
19 }
20 
21 namespace details
22 {
23 
24 template<class T>
25 template<class U>
26  requires std::constructible_from<std::shared_ptr<T>, std::shared_ptr<U>&&>
27 smart_ptr_ref_adapter<std::shared_ptr, T>::smart_ptr_ref_adapter(
28  smart_ptr_ref_adapter<std::shared_ptr, U>&& other) noexcept
29  : super(static_cast<std::shared_ptr<U>&&>(other))
30 {
31 }
32 
33 template<class T>
34 void smart_ptr_ref_adapter<std::shared_ptr, T>::reset(smart_ptr_ref_adapter other) noexcept
35 {
36  *this = std::move(other);
37 }
38 
39 template<class T>
40 typename smart_ptr_ref_adapter<std::shared_ptr, T>::original_pointer_type smart_ptr_ref_adapter<std::shared_ptr, T>::
41  to_shared_ptr()
42 {
43  return *this;
44 }
45 
46 template<class T>
47 template<class... constructor_args_t>
48 smart_ptr_ref_adapter<std::shared_ptr, T>::smart_ptr_ref_adapter(private_token, constructor_args_t&&... args)
49  : super(std::forward<constructor_args_t>(args)...)
50 {
51 }
52 
53 } // namespace details
54 
55 } // namespace qx
shared_ref< T > make_shared_ref(constructor_args_t &&... args)
Make a unique ref (same as std::make_shared but for qx::shared_ref)
Definition: shared_ref.inl:14