MCPcopy Create free account
hub / github.com/HelenOS/helenos / shared_ptr

Class shared_ptr

uspace/lib/cpp/include/__bits/memory/shared_ptr.hpp:66–407  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

64
65 template<class T>
66 class shared_ptr
67 {
68 public:
69 using element_type = T;
70
71 /**
72 * 20.8.2.2.1, constructors:
73 */
74
75 constexpr shared_ptr() noexcept
76 : payload_{}, data_{}
77 { /* DUMMY BODY */ }
78
79 template<class U>
80 explicit shared_ptr(
81 U* ptr,
82 enable_if_t<is_convertible_v<U*, element_type*>>* = nullptr
83 )
84 : payload_{}, data_{ptr}
85 {
86 try
87 {
88 payload_ = new aux::shared_payload<T>{ptr};
89 }
90 catch (const bad_alloc&)
91 {
92 delete ptr;
93
94 throw;
95 }
96 }
97
98 template<class U, class D>
99 shared_ptr(
100 U* ptr, D deleter,
101 enable_if_t<is_convertible_v<U*, element_type*>>* = nullptr
102 )
103 : shared_ptr{}
104 {
105 try
106 {
107 payload_ = new aux::shared_payload<T, D>{ptr, deleter};
108 }
109 catch (const bad_alloc&)
110 {
111 deleter(ptr);
112
113 throw;
114 }
115 }
116
117 template<class U, class D, class A>
118 shared_ptr(
119 U* ptr, D deleter, A,
120 enable_if_t<is_convertible_v<U*, element_type*>>* = nullptr
121 )
122 : shared_ptr{}
123 {

Callers

nothing calls this directly

Calls 3

moveFunction · 0.85
incrementMethod · 0.80
swapMethod · 0.45

Tested by

no test coverage detected