tmp/tmpto7whw55/{from.md → to.md}
RENAMED
|
@@ -0,0 +1,59 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
##### General <a id="util.smartptr.weak.general">[[util.smartptr.weak.general]]</a>
|
| 2 |
+
|
| 3 |
+
The `weak_ptr` class template stores a weak reference to an object that
|
| 4 |
+
is already managed by a `shared_ptr`. To access the object, a `weak_ptr`
|
| 5 |
+
can be converted to a `shared_ptr` using the member function `lock`.
|
| 6 |
+
|
| 7 |
+
``` cpp
|
| 8 |
+
namespace std {
|
| 9 |
+
template<class T> class weak_ptr {
|
| 10 |
+
public:
|
| 11 |
+
using element_type = remove_extent_t<T>;
|
| 12 |
+
|
| 13 |
+
// [util.smartptr.weak.const], constructors
|
| 14 |
+
constexpr weak_ptr() noexcept;
|
| 15 |
+
template<class Y>
|
| 16 |
+
weak_ptr(const shared_ptr<Y>& r) noexcept;
|
| 17 |
+
weak_ptr(const weak_ptr& r) noexcept;
|
| 18 |
+
template<class Y>
|
| 19 |
+
weak_ptr(const weak_ptr<Y>& r) noexcept;
|
| 20 |
+
weak_ptr(weak_ptr&& r) noexcept;
|
| 21 |
+
template<class Y>
|
| 22 |
+
weak_ptr(weak_ptr<Y>&& r) noexcept;
|
| 23 |
+
|
| 24 |
+
// [util.smartptr.weak.dest], destructor
|
| 25 |
+
~weak_ptr();
|
| 26 |
+
|
| 27 |
+
// [util.smartptr.weak.assign], assignment
|
| 28 |
+
weak_ptr& operator=(const weak_ptr& r) noexcept;
|
| 29 |
+
template<class Y>
|
| 30 |
+
weak_ptr& operator=(const weak_ptr<Y>& r) noexcept;
|
| 31 |
+
template<class Y>
|
| 32 |
+
weak_ptr& operator=(const shared_ptr<Y>& r) noexcept;
|
| 33 |
+
weak_ptr& operator=(weak_ptr&& r) noexcept;
|
| 34 |
+
template<class Y>
|
| 35 |
+
weak_ptr& operator=(weak_ptr<Y>&& r) noexcept;
|
| 36 |
+
|
| 37 |
+
// [util.smartptr.weak.mod], modifiers
|
| 38 |
+
void swap(weak_ptr& r) noexcept;
|
| 39 |
+
void reset() noexcept;
|
| 40 |
+
|
| 41 |
+
// [util.smartptr.weak.obs], observers
|
| 42 |
+
long use_count() const noexcept;
|
| 43 |
+
bool expired() const noexcept;
|
| 44 |
+
shared_ptr<T> lock() const noexcept;
|
| 45 |
+
template<class U>
|
| 46 |
+
bool owner_before(const shared_ptr<U>& b) const noexcept;
|
| 47 |
+
template<class U>
|
| 48 |
+
bool owner_before(const weak_ptr<U>& b) const noexcept;
|
| 49 |
+
};
|
| 50 |
+
|
| 51 |
+
template<class T>
|
| 52 |
+
weak_ptr(shared_ptr<T>) -> weak_ptr<T>;
|
| 53 |
+
}
|
| 54 |
+
```
|
| 55 |
+
|
| 56 |
+
Specializations of `weak_ptr` shall be *Cpp17CopyConstructible* and
|
| 57 |
+
*Cpp17CopyAssignable*, allowing their use in standard containers. The
|
| 58 |
+
template parameter `T` of `weak_ptr` may be an incomplete type.
|
| 59 |
+
|