tmp/tmpvy2njurj/{from.md → to.md}
RENAMED
|
@@ -13,29 +13,33 @@ namespace std {
|
|
| 13 |
// [util.smartptr.weak.const], constructors
|
| 14 |
constexpr weak_ptr() noexcept;
|
| 15 |
template<class Y> weak_ptr(shared_ptr<Y> const& r) noexcept;
|
| 16 |
weak_ptr(weak_ptr const& r) noexcept;
|
| 17 |
template<class Y> weak_ptr(weak_ptr<Y> const& r) noexcept;
|
|
|
|
|
|
|
| 18 |
|
| 19 |
// [util.smartptr.weak.dest], destructor
|
| 20 |
~weak_ptr();
|
| 21 |
|
| 22 |
// [util.smartptr.weak.assign], assignment
|
| 23 |
weak_ptr& operator=(weak_ptr const& r) noexcept;
|
| 24 |
template<class Y> weak_ptr& operator=(weak_ptr<Y> const& r) noexcept;
|
| 25 |
template<class Y> weak_ptr& operator=(shared_ptr<Y> const& r) noexcept;
|
|
|
|
|
|
|
| 26 |
|
| 27 |
// [util.smartptr.weak.mod], modifiers
|
| 28 |
void swap(weak_ptr& r) noexcept;
|
| 29 |
void reset() noexcept;
|
| 30 |
|
| 31 |
// [util.smartptr.weak.obs], observers
|
| 32 |
long use_count() const noexcept;
|
| 33 |
bool expired() const noexcept;
|
| 34 |
shared_ptr<T> lock() const noexcept;
|
| 35 |
-
template<class U> bool owner_before(shared_ptr<U> const& b);
|
| 36 |
-
template<class U> bool owner_before(weak_ptr<U> const& b);
|
| 37 |
};
|
| 38 |
|
| 39 |
// [util.smartptr.weak.spec], specialized algorithms
|
| 40 |
template<class T> void swap(weak_ptr<T>& a, weak_ptr<T>& b) noexcept;
|
| 41 |
} // namespace std
|
|
@@ -59,19 +63,32 @@ constexpr weak_ptr() noexcept;
|
|
| 59 |
weak_ptr(const weak_ptr& r) noexcept;
|
| 60 |
template<class Y> weak_ptr(const weak_ptr<Y>& r) noexcept;
|
| 61 |
template<class Y> weak_ptr(const shared_ptr<Y>& r) noexcept;
|
| 62 |
```
|
| 63 |
|
| 64 |
-
|
| 65 |
-
|
| 66 |
|
| 67 |
*Effects:* If `r` is *empty*, constructs an *empty* `weak_ptr` object;
|
| 68 |
otherwise, constructs a `weak_ptr` object that *shares ownership* with
|
| 69 |
`r` and stores a copy of the pointer stored in `r`.
|
| 70 |
|
| 71 |
*Postconditions:* `use_count() == r.use_count()`.
|
| 72 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 73 |
##### `weak_ptr` destructor <a id="util.smartptr.weak.dest">[[util.smartptr.weak.dest]]</a>
|
| 74 |
|
| 75 |
``` cpp
|
| 76 |
~weak_ptr();
|
| 77 |
```
|
|
@@ -90,10 +107,21 @@ template<class Y> weak_ptr& operator=(const shared_ptr<Y>& r) noexcept;
|
|
| 90 |
*Effects:* Equivalent to `weak_ptr(r).swap(*this)`.
|
| 91 |
|
| 92 |
*Remarks:* The implementation may meet the effects (and the implied
|
| 93 |
guarantees) via different means, without creating a temporary.
|
| 94 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 95 |
##### `weak_ptr` modifiers <a id="util.smartptr.weak.mod">[[util.smartptr.weak.mod]]</a>
|
| 96 |
|
| 97 |
``` cpp
|
| 98 |
void swap(weak_ptr& r) noexcept;
|
| 99 |
```
|
|
@@ -127,15 +155,16 @@ bool expired() const noexcept;
|
|
| 127 |
|
| 128 |
``` cpp
|
| 129 |
shared_ptr<T> lock() const noexcept;
|
| 130 |
```
|
| 131 |
|
| 132 |
-
*Returns:* `expired() ? shared_ptr<T>() : shared_ptr<T>(*this)`
|
|
|
|
| 133 |
|
| 134 |
``` cpp
|
| 135 |
-
template<class U> bool owner_before(shared_ptr<U> const& b);
|
| 136 |
-
template<class U> bool owner_before(weak_ptr<U> const& b);
|
| 137 |
```
|
| 138 |
|
| 139 |
*Returns:* An unspecified value such that
|
| 140 |
|
| 141 |
- `x.owner_before(y)` defines a strict weak ordering as defined
|
|
@@ -151,43 +180,5 @@ template<class U> bool owner_before(weak_ptr<U> const& b);
|
|
| 151 |
template<class T> void swap(weak_ptr<T>& a, weak_ptr<T>& b) noexcept;
|
| 152 |
```
|
| 153 |
|
| 154 |
*Effects:* Equivalent to `a.swap(b)`.
|
| 155 |
|
| 156 |
-
##### Class template `owner_less` <a id="util.smartptr.ownerless">[[util.smartptr.ownerless]]</a>
|
| 157 |
-
|
| 158 |
-
The class template `owner_less` allows ownership-based mixed comparisons
|
| 159 |
-
of shared and weak pointers.
|
| 160 |
-
|
| 161 |
-
``` cpp
|
| 162 |
-
namespace std {
|
| 163 |
-
template<class T> struct owner_less;
|
| 164 |
-
|
| 165 |
-
template<class T> struct owner_less<shared_ptr<T> > {
|
| 166 |
-
typedef bool result_type;
|
| 167 |
-
typedef shared_ptr<T> first_argument_type;
|
| 168 |
-
typedef shared_ptr<T> second_argument_type;
|
| 169 |
-
bool operator()(shared_ptr<T> const&, shared_ptr<T> const&) const;
|
| 170 |
-
bool operator()(shared_ptr<T> const&, weak_ptr<T> const&) const;
|
| 171 |
-
bool operator()(weak_ptr<T> const&, shared_ptr<T> const&) const;
|
| 172 |
-
};
|
| 173 |
-
|
| 174 |
-
template<class T> struct owner_less<weak_ptr<T> > {
|
| 175 |
-
typedef bool result_type;
|
| 176 |
-
typedef weak_ptr<T> first_argument_type;
|
| 177 |
-
typedef weak_ptr<T> second_argument_type;
|
| 178 |
-
bool operator()(weak_ptr<T> const&, weak_ptr<T> const&) const;
|
| 179 |
-
bool operator()(shared_ptr<T> const&, weak_ptr<T> const&) const;
|
| 180 |
-
bool operator()(weak_ptr<T> const&, shared_ptr<T> const&) const;
|
| 181 |
-
};
|
| 182 |
-
}
|
| 183 |
-
```
|
| 184 |
-
|
| 185 |
-
`operator()(x,y)` shall return `x.owner_before(y)`. Note that
|
| 186 |
-
|
| 187 |
-
- `operator()` defines a strict weak ordering as defined in
|
| 188 |
-
[[alg.sorting]];
|
| 189 |
-
- under the equivalence relation defined by `operator()`,
|
| 190 |
-
`!operator()(a, b) && !operator()(b, a)`, two `shared_ptr` or
|
| 191 |
-
`weak_ptr` instances are equivalent if and only if they share
|
| 192 |
-
ownership or are both empty.
|
| 193 |
-
|
|
|
|
| 13 |
// [util.smartptr.weak.const], constructors
|
| 14 |
constexpr weak_ptr() noexcept;
|
| 15 |
template<class Y> weak_ptr(shared_ptr<Y> const& r) noexcept;
|
| 16 |
weak_ptr(weak_ptr const& r) noexcept;
|
| 17 |
template<class Y> weak_ptr(weak_ptr<Y> const& r) noexcept;
|
| 18 |
+
weak_ptr(weak_ptr&& r) noexcept;
|
| 19 |
+
template<class Y> weak_ptr(weak_ptr<Y>&& r) noexcept;
|
| 20 |
|
| 21 |
// [util.smartptr.weak.dest], destructor
|
| 22 |
~weak_ptr();
|
| 23 |
|
| 24 |
// [util.smartptr.weak.assign], assignment
|
| 25 |
weak_ptr& operator=(weak_ptr const& r) noexcept;
|
| 26 |
template<class Y> weak_ptr& operator=(weak_ptr<Y> const& r) noexcept;
|
| 27 |
template<class Y> weak_ptr& operator=(shared_ptr<Y> const& r) noexcept;
|
| 28 |
+
weak_ptr& operator=(weak_ptr&& r) noexcept;
|
| 29 |
+
template<class Y> weak_ptr& operator=(weak_ptr<Y>&& r) noexcept;
|
| 30 |
|
| 31 |
// [util.smartptr.weak.mod], modifiers
|
| 32 |
void swap(weak_ptr& r) noexcept;
|
| 33 |
void reset() noexcept;
|
| 34 |
|
| 35 |
// [util.smartptr.weak.obs], observers
|
| 36 |
long use_count() const noexcept;
|
| 37 |
bool expired() const noexcept;
|
| 38 |
shared_ptr<T> lock() const noexcept;
|
| 39 |
+
template<class U> bool owner_before(shared_ptr<U> const& b) const;
|
| 40 |
+
template<class U> bool owner_before(weak_ptr<U> const& b) const;
|
| 41 |
};
|
| 42 |
|
| 43 |
// [util.smartptr.weak.spec], specialized algorithms
|
| 44 |
template<class T> void swap(weak_ptr<T>& a, weak_ptr<T>& b) noexcept;
|
| 45 |
} // namespace std
|
|
|
|
| 63 |
weak_ptr(const weak_ptr& r) noexcept;
|
| 64 |
template<class Y> weak_ptr(const weak_ptr<Y>& r) noexcept;
|
| 65 |
template<class Y> weak_ptr(const shared_ptr<Y>& r) noexcept;
|
| 66 |
```
|
| 67 |
|
| 68 |
+
The second and third constructors shall not participate in overload
|
| 69 |
+
resolution unless `Y*` is implicitly convertible to `T*`.
|
| 70 |
|
| 71 |
*Effects:* If `r` is *empty*, constructs an *empty* `weak_ptr` object;
|
| 72 |
otherwise, constructs a `weak_ptr` object that *shares ownership* with
|
| 73 |
`r` and stores a copy of the pointer stored in `r`.
|
| 74 |
|
| 75 |
*Postconditions:* `use_count() == r.use_count()`.
|
| 76 |
|
| 77 |
+
``` cpp
|
| 78 |
+
weak_ptr(weak_ptr&& r) noexcept;
|
| 79 |
+
template<class Y> weak_ptr(weak_ptr<Y>&& r) noexcept;
|
| 80 |
+
```
|
| 81 |
+
|
| 82 |
+
The second constructor shall not participate in overload resolution
|
| 83 |
+
unless `Y*` is implicitly convertible to `T*`.
|
| 84 |
+
|
| 85 |
+
*Effects:* Move-constructs a `weak_ptr` instance from `r`.
|
| 86 |
+
|
| 87 |
+
*Postconditions:* `*this` shall contain the old value of `r`. `r` shall
|
| 88 |
+
be *empty*. `r.use_count() == 0`.
|
| 89 |
+
|
| 90 |
##### `weak_ptr` destructor <a id="util.smartptr.weak.dest">[[util.smartptr.weak.dest]]</a>
|
| 91 |
|
| 92 |
``` cpp
|
| 93 |
~weak_ptr();
|
| 94 |
```
|
|
|
|
| 107 |
*Effects:* Equivalent to `weak_ptr(r).swap(*this)`.
|
| 108 |
|
| 109 |
*Remarks:* The implementation may meet the effects (and the implied
|
| 110 |
guarantees) via different means, without creating a temporary.
|
| 111 |
|
| 112 |
+
*Returns:* `*this`.
|
| 113 |
+
|
| 114 |
+
``` cpp
|
| 115 |
+
weak_ptr& operator=(weak_ptr&& r) noexcept;
|
| 116 |
+
template<class Y> weak_ptr& operator=(weak_ptr<Y>&& r) noexcept;
|
| 117 |
+
```
|
| 118 |
+
|
| 119 |
+
*Effects:* Equivalent to `weak_ptr(std::move(r)).swap(*this)`.
|
| 120 |
+
|
| 121 |
+
*Returns:* `*this`.
|
| 122 |
+
|
| 123 |
##### `weak_ptr` modifiers <a id="util.smartptr.weak.mod">[[util.smartptr.weak.mod]]</a>
|
| 124 |
|
| 125 |
``` cpp
|
| 126 |
void swap(weak_ptr& r) noexcept;
|
| 127 |
```
|
|
|
|
| 155 |
|
| 156 |
``` cpp
|
| 157 |
shared_ptr<T> lock() const noexcept;
|
| 158 |
```
|
| 159 |
|
| 160 |
+
*Returns:* `expired() ? shared_ptr<T>() : shared_ptr<T>(*this)`,
|
| 161 |
+
executed atomically.
|
| 162 |
|
| 163 |
``` cpp
|
| 164 |
+
template<class U> bool owner_before(shared_ptr<U> const& b) const;
|
| 165 |
+
template<class U> bool owner_before(weak_ptr<U> const& b) const;
|
| 166 |
```
|
| 167 |
|
| 168 |
*Returns:* An unspecified value such that
|
| 169 |
|
| 170 |
- `x.owner_before(y)` defines a strict weak ordering as defined
|
|
|
|
| 180 |
template<class T> void swap(weak_ptr<T>& a, weak_ptr<T>& b) noexcept;
|
| 181 |
```
|
| 182 |
|
| 183 |
*Effects:* Equivalent to `a.swap(b)`.
|
| 184 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|