From Jason Turner

[util.smartptr.weak]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmpa7yzfx4l/{from.md → to.md} +64 -42
tmp/tmpa7yzfx4l/{from.md → to.md} RENAMED
@@ -13,43 +13,48 @@ namespace std {
13
  using element_type = remove_extent_t<T>;
14
 
15
  // [util.smartptr.weak.const], constructors
16
  constexpr weak_ptr() noexcept;
17
  template<class Y>
18
- weak_ptr(const shared_ptr<Y>& r) noexcept;
19
- weak_ptr(const weak_ptr& r) noexcept;
20
  template<class Y>
21
- weak_ptr(const weak_ptr<Y>& r) noexcept;
22
- weak_ptr(weak_ptr&& r) noexcept;
23
  template<class Y>
24
- weak_ptr(weak_ptr<Y>&& r) noexcept;
25
 
26
  // [util.smartptr.weak.dest], destructor
27
- ~weak_ptr();
28
 
29
  // [util.smartptr.weak.assign], assignment
30
- weak_ptr& operator=(const weak_ptr& r) noexcept;
31
  template<class Y>
32
- weak_ptr& operator=(const weak_ptr<Y>& r) noexcept;
33
  template<class Y>
34
- weak_ptr& operator=(const shared_ptr<Y>& r) noexcept;
35
- weak_ptr& operator=(weak_ptr&& r) noexcept;
36
  template<class Y>
37
- weak_ptr& operator=(weak_ptr<Y>&& r) noexcept;
38
 
39
  // [util.smartptr.weak.mod], modifiers
40
- void swap(weak_ptr& r) noexcept;
41
- void reset() noexcept;
42
 
43
  // [util.smartptr.weak.obs], observers
44
- long use_count() const noexcept;
45
- bool expired() const noexcept;
46
- shared_ptr<T> lock() const noexcept;
47
  template<class U>
48
- bool owner_before(const shared_ptr<U>& b) const noexcept;
49
  template<class U>
50
- bool owner_before(const weak_ptr<U>& b) const noexcept;
 
 
 
 
 
51
  };
52
 
53
  template<class T>
54
  weak_ptr(shared_ptr<T>) -> weak_ptr<T>;
55
  }
@@ -69,13 +74,13 @@ constexpr weak_ptr() noexcept;
69
  pointer value.
70
 
71
  *Ensures:* `use_count() == 0`.
72
 
73
  ``` cpp
74
- weak_ptr(const weak_ptr& r) noexcept;
75
- template<class Y> weak_ptr(const weak_ptr<Y>& r) noexcept;
76
- template<class Y> weak_ptr(const shared_ptr<Y>& r) noexcept;
77
  ```
78
 
79
  *Constraints:* For the second and third constructors, `Y*` is compatible
80
  with `T*`.
81
 
@@ -85,12 +90,12 @@ that shares ownership with `r` and stores a copy of the pointer stored
85
  in `r`.
86
 
87
  *Ensures:* `use_count() == r.use_count()`.
88
 
89
  ``` cpp
90
- weak_ptr(weak_ptr&& r) noexcept;
91
- template<class Y> weak_ptr(weak_ptr<Y>&& r) noexcept;
92
  ```
93
 
94
  *Constraints:* For the second constructor, `Y*` is compatible with `T*`.
95
 
96
  *Effects:* Move constructs a `weak_ptr` instance from `r`.
@@ -99,94 +104,111 @@ template<class Y> weak_ptr(weak_ptr<Y>&& r) noexcept;
99
  null pointer value, and `r.use_count() == 0`.
100
 
101
  ##### Destructor <a id="util.smartptr.weak.dest">[[util.smartptr.weak.dest]]</a>
102
 
103
  ``` cpp
104
- ~weak_ptr();
105
  ```
106
 
107
  *Effects:* Destroys this `weak_ptr` object but has no effect on the
108
  object its stored pointer points to.
109
 
110
  ##### Assignment <a id="util.smartptr.weak.assign">[[util.smartptr.weak.assign]]</a>
111
 
112
  ``` cpp
113
- weak_ptr& operator=(const weak_ptr& r) noexcept;
114
- template<class Y> weak_ptr& operator=(const weak_ptr<Y>& r) noexcept;
115
- template<class Y> weak_ptr& operator=(const shared_ptr<Y>& r) noexcept;
116
  ```
117
 
118
  *Effects:* Equivalent to `weak_ptr(r).swap(*this)`.
119
 
120
  *Returns:* `*this`.
121
 
122
  *Remarks:* The implementation may meet the effects (and the implied
123
  guarantees) via different means, without creating a temporary object.
124
 
125
  ``` cpp
126
- weak_ptr& operator=(weak_ptr&& r) noexcept;
127
- template<class Y> weak_ptr& operator=(weak_ptr<Y>&& r) noexcept;
128
  ```
129
 
130
  *Effects:* Equivalent to `weak_ptr(std::move(r)).swap(*this)`.
131
 
132
  *Returns:* `*this`.
133
 
134
  ##### Modifiers <a id="util.smartptr.weak.mod">[[util.smartptr.weak.mod]]</a>
135
 
136
  ``` cpp
137
- void swap(weak_ptr& r) noexcept;
138
  ```
139
 
140
  *Effects:* Exchanges the contents of `*this` and `r`.
141
 
142
  ``` cpp
143
- void reset() noexcept;
144
  ```
145
 
146
  *Effects:* Equivalent to `weak_ptr().swap(*this)`.
147
 
148
  ##### Observers <a id="util.smartptr.weak.obs">[[util.smartptr.weak.obs]]</a>
149
 
150
  ``` cpp
151
- long use_count() const noexcept;
152
  ```
153
 
154
  *Returns:* `0` if `*this` is empty; otherwise, the number of
155
  `shared_ptr` instances that share ownership with `*this`.
156
 
157
  ``` cpp
158
- bool expired() const noexcept;
159
  ```
160
 
161
  *Returns:* `use_count() == 0`.
162
 
163
  ``` cpp
164
- shared_ptr<T> lock() const noexcept;
165
  ```
166
 
167
  *Returns:* `expired() ? shared_ptr<T>() : shared_ptr<T>(*this)`,
168
  executed atomically.
169
 
170
  ``` cpp
171
- template<class U> bool owner_before(const shared_ptr<U>& b) const noexcept;
172
- template<class U> bool owner_before(const weak_ptr<U>& b) const noexcept;
173
  ```
174
 
175
  *Returns:* An unspecified value such that
176
 
177
- - `x.owner_before(y)` defines a strict weak ordering as defined
178
  in  [[alg.sorting]];
179
- - under the equivalence relation defined by `owner_before`,
180
- `!a.owner_before(b) && !b.owner_before(a)`, two `shared_ptr` or
181
- `weak_ptr` instances are equivalent if and only if they share
182
- ownership or are both empty.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
183
 
184
  ##### Specialized algorithms <a id="util.smartptr.weak.spec">[[util.smartptr.weak.spec]]</a>
185
 
186
  ``` cpp
187
  template<class T>
188
- void swap(weak_ptr<T>& a, weak_ptr<T>& b) noexcept;
189
  ```
190
 
191
  *Effects:* Equivalent to `a.swap(b)`.
192
 
 
13
  using element_type = remove_extent_t<T>;
14
 
15
  // [util.smartptr.weak.const], constructors
16
  constexpr weak_ptr() noexcept;
17
  template<class Y>
18
+ constexpr weak_ptr(const shared_ptr<Y>& r) noexcept;
19
+ constexpr weak_ptr(const weak_ptr& r) noexcept;
20
  template<class Y>
21
+ constexpr weak_ptr(const weak_ptr<Y>& r) noexcept;
22
+ constexpr weak_ptr(weak_ptr&& r) noexcept;
23
  template<class Y>
24
+ constexpr weak_ptr(weak_ptr<Y>&& r) noexcept;
25
 
26
  // [util.smartptr.weak.dest], destructor
27
+ constexpr ~weak_ptr();
28
 
29
  // [util.smartptr.weak.assign], assignment
30
+ constexpr weak_ptr& operator=(const weak_ptr& r) noexcept;
31
  template<class Y>
32
+ constexpr weak_ptr& operator=(const weak_ptr<Y>& r) noexcept;
33
  template<class Y>
34
+ constexpr weak_ptr& operator=(const shared_ptr<Y>& r) noexcept;
35
+ constexpr weak_ptr& operator=(weak_ptr&& r) noexcept;
36
  template<class Y>
37
+ constexpr weak_ptr& operator=(weak_ptr<Y>&& r) noexcept;
38
 
39
  // [util.smartptr.weak.mod], modifiers
40
+ constexpr void swap(weak_ptr& r) noexcept;
41
+ constexpr void reset() noexcept;
42
 
43
  // [util.smartptr.weak.obs], observers
44
+ constexpr long use_count() const noexcept;
45
+ constexpr bool expired() const noexcept;
46
+ constexpr shared_ptr<T> lock() const noexcept;
47
  template<class U>
48
+ constexpr bool owner_before(const shared_ptr<U>& b) const noexcept;
49
  template<class U>
50
+ constexpr bool owner_before(const weak_ptr<U>& b) const noexcept;
51
+ size_t owner_hash() const noexcept;
52
+ template<class U>
53
+ constexpr bool owner_equal(const shared_ptr<U>& b) const noexcept;
54
+ template<class U>
55
+ constexpr bool owner_equal(const weak_ptr<U>& b) const noexcept;
56
  };
57
 
58
  template<class T>
59
  weak_ptr(shared_ptr<T>) -> weak_ptr<T>;
60
  }
 
74
  pointer value.
75
 
76
  *Ensures:* `use_count() == 0`.
77
 
78
  ``` cpp
79
+ constexpr weak_ptr(const weak_ptr& r) noexcept;
80
+ template<class Y> constexpr weak_ptr(const weak_ptr<Y>& r) noexcept;
81
+ template<class Y> constexpr weak_ptr(const shared_ptr<Y>& r) noexcept;
82
  ```
83
 
84
  *Constraints:* For the second and third constructors, `Y*` is compatible
85
  with `T*`.
86
 
 
90
  in `r`.
91
 
92
  *Ensures:* `use_count() == r.use_count()`.
93
 
94
  ``` cpp
95
+ constexpr weak_ptr(weak_ptr&& r) noexcept;
96
+ template<class Y> constexpr weak_ptr(weak_ptr<Y>&& r) noexcept;
97
  ```
98
 
99
  *Constraints:* For the second constructor, `Y*` is compatible with `T*`.
100
 
101
  *Effects:* Move constructs a `weak_ptr` instance from `r`.
 
104
  null pointer value, and `r.use_count() == 0`.
105
 
106
  ##### Destructor <a id="util.smartptr.weak.dest">[[util.smartptr.weak.dest]]</a>
107
 
108
  ``` cpp
109
+ constexpr ~weak_ptr();
110
  ```
111
 
112
  *Effects:* Destroys this `weak_ptr` object but has no effect on the
113
  object its stored pointer points to.
114
 
115
  ##### Assignment <a id="util.smartptr.weak.assign">[[util.smartptr.weak.assign]]</a>
116
 
117
  ``` cpp
118
+ constexpr weak_ptr& operator=(const weak_ptr& r) noexcept;
119
+ template<class Y> constexpr weak_ptr& operator=(const weak_ptr<Y>& r) noexcept;
120
+ template<class Y> constexpr weak_ptr& operator=(const shared_ptr<Y>& r) noexcept;
121
  ```
122
 
123
  *Effects:* Equivalent to `weak_ptr(r).swap(*this)`.
124
 
125
  *Returns:* `*this`.
126
 
127
  *Remarks:* The implementation may meet the effects (and the implied
128
  guarantees) via different means, without creating a temporary object.
129
 
130
  ``` cpp
131
+ constexpr weak_ptr& operator=(weak_ptr&& r) noexcept;
132
+ template<class Y> constexpr weak_ptr& operator=(weak_ptr<Y>&& r) noexcept;
133
  ```
134
 
135
  *Effects:* Equivalent to `weak_ptr(std::move(r)).swap(*this)`.
136
 
137
  *Returns:* `*this`.
138
 
139
  ##### Modifiers <a id="util.smartptr.weak.mod">[[util.smartptr.weak.mod]]</a>
140
 
141
  ``` cpp
142
+ constexpr void swap(weak_ptr& r) noexcept;
143
  ```
144
 
145
  *Effects:* Exchanges the contents of `*this` and `r`.
146
 
147
  ``` cpp
148
+ constexpr void reset() noexcept;
149
  ```
150
 
151
  *Effects:* Equivalent to `weak_ptr().swap(*this)`.
152
 
153
  ##### Observers <a id="util.smartptr.weak.obs">[[util.smartptr.weak.obs]]</a>
154
 
155
  ``` cpp
156
+ constexpr long use_count() const noexcept;
157
  ```
158
 
159
  *Returns:* `0` if `*this` is empty; otherwise, the number of
160
  `shared_ptr` instances that share ownership with `*this`.
161
 
162
  ``` cpp
163
+ constexpr bool expired() const noexcept;
164
  ```
165
 
166
  *Returns:* `use_count() == 0`.
167
 
168
  ``` cpp
169
+ constexpr shared_ptr<T> lock() const noexcept;
170
  ```
171
 
172
  *Returns:* `expired() ? shared_ptr<T>() : shared_ptr<T>(*this)`,
173
  executed atomically.
174
 
175
  ``` cpp
176
+ template<class U> constexpr bool owner_before(const shared_ptr<U>& b) const noexcept;
177
+ template<class U> constexpr bool owner_before(const weak_ptr<U>& b) const noexcept;
178
  ```
179
 
180
  *Returns:* An unspecified value such that
181
 
182
+ - `owner_before(b)` defines a strict weak ordering as defined
183
  in  [[alg.sorting]];
184
+ - `!owner_before(b) && !b.owner_before(*this)` is `true` if and only if
185
+ `owner_equal(b)` is `true`.
186
+
187
+ ``` cpp
188
+ size_t owner_hash() const noexcept;
189
+ ```
190
+
191
+ *Returns:* An unspecified value such that, for any object `x` where
192
+ `owner_equal(x)` is `true`, `owner_hash() == x.owner_hash()` is `true`.
193
+
194
+ ``` cpp
195
+ template<class U>
196
+ constexpr bool owner_equal(const shared_ptr<U>& b) const noexcept;
197
+ template<class U>
198
+ constexpr bool owner_equal(const weak_ptr<U>& b) const noexcept;
199
+ ```
200
+
201
+ *Returns:* `true` if and only if `*this` and `b` share ownership or are
202
+ both empty. Otherwise returns `false`.
203
+
204
+ *Remarks:* `owner_equal` is an equivalence relation.
205
 
206
  ##### Specialized algorithms <a id="util.smartptr.weak.spec">[[util.smartptr.weak.spec]]</a>
207
 
208
  ``` cpp
209
  template<class T>
210
+ constexpr void swap(weak_ptr<T>& a, weak_ptr<T>& b) noexcept;
211
  ```
212
 
213
  *Effects:* Equivalent to `a.swap(b)`.
214