Changeset de00da5 in mainline
- Timestamp:
- 2018-07-05T21:41:23Z (7 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 6a3a64f
- Parents:
- 09e02ee
- git-author:
- Dzejrou <dzejrou@…> (2018-05-09 23:42:29)
- git-committer:
- Dzejrou <dzejrou@…> (2018-07-05 21:41:23)
- Location:
- uspace/lib/cpp/include/internal/memory
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/cpp/include/internal/memory/shared_payload.hpp
r09e02ee rde00da5 49 49 using refcount_t = long; 50 50 51 /** 52 * This allows us to construct shared_ptr from 53 * a payload pointer in make_shared etc. 54 */ 55 struct payload_tag_t 56 { /* DUMMY BODY */ }; 57 58 inline constexpr payload_tag_t payload_tag{}; 59 51 60 template<class D, class T> 52 61 void use_payload_deleter(D* deleter, T* data) -
uspace/lib/cpp/include/internal/memory/shared_ptr.hpp
r09e02ee rde00da5 76 76 template<class U> 77 77 explicit shared_ptr( 78 enable_if_t<is_convertible_v<U*, element_type*>, U*> ptr 78 U* ptr, 79 enable_if_t<is_convertible_v<U*, element_type*>>* = nullptr 79 80 ) 80 81 : payload_{}, data_{ptr} … … 94 95 template<class U, class D> 95 96 shared_ptr( 96 enable_if_t<is_convertible_v<U*, element_type*>, U*> ptr, D deleter 97 U* ptr, D deleter, 98 enable_if_t<is_convertible_v<U*, element_type*>>* = nullptr 97 99 ) 98 100 : shared_ptr{} … … 112 114 template<class U, class D, class A> 113 115 shared_ptr( 114 enable_if_t<is_convertible_v<U*, element_type*>, U*> ptr,115 D deleter, A116 U* ptr, D deleter, A, 117 enable_if_t<is_convertible_v<U*, element_type*>>* = nullptr 116 118 ) 117 119 : shared_ptr{} … … 141 143 template<class U> 142 144 shared_ptr( 143 enable_if_t<is_convertible_v<U*, element_type*>, const shared_ptr<U>&> other,144 e lement_type*ptr145 const shared_ptr<U>& other, element_type* ptr, 146 enable_if_t<is_convertible_v<U*, element_type*>>* = nullptr 145 147 ) 146 148 : payload_{other.payload_}, data_{ptr} … … 159 161 template<class U> 160 162 shared_ptr( 161 enable_if_t<is_convertible_v<U*, element_type*>, const shared_ptr<U>&> other 163 const shared_ptr<U>& other, 164 enable_if_t<is_convertible_v<U*, element_type*>>* = nullptr 162 165 ) 163 166 : payload_{other.payload_}, data_{other.data_} … … 176 179 template<class U> 177 180 shared_ptr( 178 enable_if_t<is_convertible_v<U*, element_type*>, shared_ptr<U>&&> other 181 shared_ptr<U>&& other, 182 enable_if_t<is_convertible_v<U*, element_type*>>* = nullptr 179 183 ) 180 184 : payload_{move(other.payload_)}, data_{move(other.data_)} … … 186 190 template<class U> 187 191 explicit shared_ptr( 188 enable_if_t<is_convertible_v<U*, element_type*>, const weak_ptr<U>&> other 192 const weak_ptr<U>& other, 193 enable_if_t<is_convertible_v<U*, element_type*>>* = nullptr 189 194 ) 190 195 { … … 196 201 template<class U, class D> 197 202 shared_ptr( 203 unique_ptr<U, D>&& other, 198 204 enable_if_t< 199 205 is_convertible_v< 200 206 typename unique_ptr<U, D>::pointer, 201 207 element_type* 202 >, 203 unique_ptr<U, D>&& 204 > other 208 > 209 >* = nullptr 205 210 ) // TODO: if D is a reference type, it should be ref(other.get_deleter()) 206 211 : shared_ptr{other.release(), other.get_deleter()} … … 238 243 239 244 template<class U> 240 shared_ptr& operator=( 241 enable_if_t<is_convertible_v<U*, element_type*>, const shared_ptr<U>&> rhs 242 ) noexcept 245 enable_if_t<is_convertible_v<U*, element_type*>, shared_ptr>& 246 operator=(const shared_ptr<U>& rhs) noexcept 243 247 { 244 248 if (rhs.payload_) … … 261 265 262 266 template<class U> 263 shared_ptr& operator=( 264 enable_if_t<is_convertible_v<U*, element_type*>, shared_ptr<U>&&> rhs 265 ) noexcept 267 shared_ptr& operator=(shared_ptr<U>&& rhs) noexcept 266 268 { 267 269 shared_ptr{move(rhs)}.swap(*this); … … 364 366 element_type* data_; 365 367 366 shared_ptr(aux:: shared_payload_base<element_type>* payload)368 shared_ptr(aux::payload_tag_t, aux::shared_payload_base<element_type>* payload) 367 369 : payload_{payload}, data_{payload->get()} 368 370 { /* DUMMY BODY */ } … … 409 411 { 410 412 return shared_ptr<T>{ 413 aux::payload_tag, 411 414 new aux::shared_payload<T>{forward<Args>(args)...} 412 415 }; … … 417 420 { 418 421 return shared_ptr<T>{ 422 aux::payload_tag, 419 423 new aux::shared_payload<T>{allocator_arg, A{alloc}, forward<Args>(args)...} 420 424 }; -
uspace/lib/cpp/include/internal/memory/weak_ptr.hpp
r09e02ee rde00da5 192 192 shared_ptr<T> lock() const noexcept 193 193 { 194 return shared_ptr{ payload_->lock()};194 return shared_ptr{aux::payload_tag, payload_->lock()}; 195 195 } 196 196
Note:
See TracChangeset
for help on using the changeset viewer.