| 207 | template<typename T> |
| 208 | template<typename Y> |
| 209 | shared_ptr<T>::shared_ptr(const weak_ptr<Y>& weak) : mPtr(nullptr), mControlBlock(nullptr) { |
| 210 | if (!weak.expired()) { |
| 211 | if (weak.mControlBlock && weak.mControlBlock->shared_count > 0) { |
| 212 | ++weak.mControlBlock->shared_count; |
| 213 | mPtr = weak.mPtr; |
| 214 | mControlBlock = weak.mControlBlock; |
| 215 | } |
| 216 | } |
| 217 | if (!mPtr) { |
| 218 | // If construction failed (object was destroyed), throw bad_weak_ptr equivalent |
| 219 | // For now, just leave as default-constructed (nullptr) |
| 220 | } |
| 221 | } |
| 222 | |
| 223 | } // namespace fl |