From Jason Turner

[smartptr.adapt]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmpbtxmvczh/{from.md → to.md} +17 -20
tmp/tmpbtxmvczh/{from.md → to.md} RENAMED
@@ -39,16 +39,16 @@ pointer value and manually delete it on error or failure.
39
  ``` cpp
40
  namespace std {
41
  template<class Smart, class Pointer, class... Args>
42
  class out_ptr_t {
43
  public:
44
- explicit out_ptr_t(Smart&, Args...);
45
  out_ptr_t(const out_ptr_t&) = delete;
46
 
47
- ~out_ptr_t();
48
 
49
- operator Pointer*() const noexcept;
50
  operator void**() const noexcept;
51
 
52
  private:
53
  Smart& s; // exposition only
54
  tuple<Args...> a; // exposition only
@@ -72,41 +72,40 @@ template.
72
 
73
  Evaluations of the conversion functions on the same object may conflict
74
  [[intro.races]].
75
 
76
  ``` cpp
77
- explicit out_ptr_t(Smart& smart, Args... args);
78
  ```
79
 
80
  *Effects:* Initializes `s` with `smart`, `a` with
81
  `std::forward<Args>(args)...`, and value-initializes `p`. Then,
82
  equivalent to:
83
 
84
- - ``` cpp
 
85
  s.reset();
86
  ```
87
 
88
  if the expression `s.reset()` is well-formed;
89
-
90
  - otherwise,
91
  ``` cpp
92
  s = Smart();
93
  ```
94
 
95
  if `is_constructible_v<Smart>` is `true`;
96
-
97
  - otherwise, the program is ill-formed.
98
 
99
  [*Note 1*: The constructor is not `noexcept` to allow for a variety of
100
  non-terminating and safe implementation strategies. For example, an
101
  implementation can allocate a `shared_ptr`’s internal node in the
102
  constructor and let implementation-defined exceptions escape safely. The
103
  destructor can then move the allocated control block in directly and
104
  avoid any other exceptions. — *end note*]
105
 
106
  ``` cpp
107
- ~out_ptr_t();
108
  ```
109
 
110
  Let `SP` be *`POINTER_OF_OR`*`(Smart, Pointer)` [[memory.general]].
111
 
112
  *Effects:* Equivalent to:
@@ -132,11 +131,11 @@ Let `SP` be *`POINTER_OF_OR`*`(Smart, Pointer)` [[memory.general]].
132
 
133
  if `is_constructible_v<Smart, SP, Args...>` is `true`;
134
  - otherwise, the program is ill-formed.
135
 
136
  ``` cpp
137
- operator Pointer*() const noexcept;
138
  ```
139
 
140
  *Preconditions:* `operator void**()` has not been called on `*this`.
141
 
142
  *Returns:* `addressof(const_cast<Pointer&>(p))`.
@@ -167,18 +166,18 @@ implementations. — *end note*]
167
 
168
  #### Function template `out_ptr` <a id="out.ptr">[[out.ptr]]</a>
169
 
170
  ``` cpp
171
  template<class Pointer = void, class Smart, class... Args>
172
- auto out_ptr(Smart& s, Args&&... args);
173
  ```
174
 
175
  Let `P` be `Pointer` if `is_void_v<Pointer>` is `false`, otherwise
176
  *`POINTER_OF`*`(Smart)`.
177
 
178
  *Returns:*
179
- `out_ptr_t<Smart, P, Args&&...>(s, std::forward<Args>(args)...)`
180
 
181
  #### Class template `inout_ptr_t` <a id="inout.ptr.t">[[inout.ptr.t]]</a>
182
 
183
  `inout_ptr_t` is a class template used to adapt types such as smart
184
  pointers [[smartptr]] for functions that use output pointer parameters
@@ -218,16 +217,16 @@ place.
218
  ``` cpp
219
  namespace std {
220
  template<class Smart, class Pointer, class... Args>
221
  class inout_ptr_t {
222
  public:
223
- explicit inout_ptr_t(Smart&, Args...);
224
  inout_ptr_t(const inout_ptr_t&) = delete;
225
 
226
- ~inout_ptr_t();
227
 
228
- operator Pointer*() const noexcept;
229
  operator void**() const noexcept;
230
 
231
  private:
232
  Smart& s; // exposition only
233
  tuple<Args...> a; // exposition only
@@ -249,11 +248,11 @@ template.
249
 
250
  Evaluations of the conversion functions on the same object may conflict
251
  [[intro.races]].
252
 
253
  ``` cpp
254
- explicit inout_ptr_t(Smart& smart, Args... args);
255
  ```
256
 
257
  *Effects:* Initializes `s` with `smart`, `a` with
258
  `std::forward<Args>(args)...`, and `p` to either
259
 
@@ -266,11 +265,11 @@ explicit inout_ptr_t(Smart& smart, Args... args);
266
  non-terminating and safe implementation strategies. For example, an
267
  intrusive pointer implementation with a control block can allocate in
268
  the constructor and safely fail with an exception. — *end note*]
269
 
270
  ``` cpp
271
- ~inout_ptr_t();
272
  ```
273
 
274
  Let `SP` be *`POINTER_OF_OR`*`(Smart, Pointer)` [[memory.general]].
275
 
276
  Let *release-statement* be `s.release();` if an implementation does not
@@ -278,14 +277,12 @@ call `s.release()` in the constructor. Otherwise, it is empty.
278
 
279
  *Effects:* Equivalent to:
280
 
281
  -
282
  ``` cpp
283
- if (p) {
284
  apply([&](auto&&... args) {
285
  s = Smart(static_cast<SP>(p), std::forward<Args>(args)...); }, std::move(a));
286
- }
287
  ```
288
 
289
  if `is_pointer_v<Smart>` is `true`;
290
  - otherwise,
291
  ``` cpp
@@ -310,11 +307,11 @@ call `s.release()` in the constructor. Otherwise, it is empty.
310
 
311
  if `is_constructible_v<Smart, SP, Args...>` is `true`;
312
  - otherwise, the program is ill-formed.
313
 
314
  ``` cpp
315
- operator Pointer*() const noexcept;
316
  ```
317
 
318
  *Preconditions:* `operator void**()` has not been called on `*this`.
319
 
320
  *Returns:* `addressof(const_cast<Pointer&>(p))`.
@@ -345,11 +342,11 @@ implementations. — *end note*]
345
 
346
  #### Function template `inout_ptr` <a id="inout.ptr">[[inout.ptr]]</a>
347
 
348
  ``` cpp
349
  template<class Pointer = void, class Smart, class... Args>
350
- auto inout_ptr(Smart& s, Args&&... args);
351
  ```
352
 
353
  Let `P` be `Pointer` if `is_void_v<Pointer>` is `false`, otherwise
354
  *`POINTER_OF`*`(Smart)`.
355
 
 
39
  ``` cpp
40
  namespace std {
41
  template<class Smart, class Pointer, class... Args>
42
  class out_ptr_t {
43
  public:
44
+ constexpr explicit out_ptr_t(Smart&, Args...);
45
  out_ptr_t(const out_ptr_t&) = delete;
46
 
47
+ constexpr ~out_ptr_t();
48
 
49
+ constexpr operator Pointer*() const noexcept;
50
  operator void**() const noexcept;
51
 
52
  private:
53
  Smart& s; // exposition only
54
  tuple<Args...> a; // exposition only
 
72
 
73
  Evaluations of the conversion functions on the same object may conflict
74
  [[intro.races]].
75
 
76
  ``` cpp
77
+ constexpr explicit out_ptr_t(Smart& smart, Args... args);
78
  ```
79
 
80
  *Effects:* Initializes `s` with `smart`, `a` with
81
  `std::forward<Args>(args)...`, and value-initializes `p`. Then,
82
  equivalent to:
83
 
84
+ -
85
+ ``` cpp
86
  s.reset();
87
  ```
88
 
89
  if the expression `s.reset()` is well-formed;
 
90
  - otherwise,
91
  ``` cpp
92
  s = Smart();
93
  ```
94
 
95
  if `is_constructible_v<Smart>` is `true`;
 
96
  - otherwise, the program is ill-formed.
97
 
98
  [*Note 1*: The constructor is not `noexcept` to allow for a variety of
99
  non-terminating and safe implementation strategies. For example, an
100
  implementation can allocate a `shared_ptr`’s internal node in the
101
  constructor and let implementation-defined exceptions escape safely. The
102
  destructor can then move the allocated control block in directly and
103
  avoid any other exceptions. — *end note*]
104
 
105
  ``` cpp
106
+ constexpr ~out_ptr_t();
107
  ```
108
 
109
  Let `SP` be *`POINTER_OF_OR`*`(Smart, Pointer)` [[memory.general]].
110
 
111
  *Effects:* Equivalent to:
 
131
 
132
  if `is_constructible_v<Smart, SP, Args...>` is `true`;
133
  - otherwise, the program is ill-formed.
134
 
135
  ``` cpp
136
+ constexpr operator Pointer*() const noexcept;
137
  ```
138
 
139
  *Preconditions:* `operator void**()` has not been called on `*this`.
140
 
141
  *Returns:* `addressof(const_cast<Pointer&>(p))`.
 
166
 
167
  #### Function template `out_ptr` <a id="out.ptr">[[out.ptr]]</a>
168
 
169
  ``` cpp
170
  template<class Pointer = void, class Smart, class... Args>
171
+ constexpr auto out_ptr(Smart& s, Args&&... args);
172
  ```
173
 
174
  Let `P` be `Pointer` if `is_void_v<Pointer>` is `false`, otherwise
175
  *`POINTER_OF`*`(Smart)`.
176
 
177
  *Returns:*
178
+ `out_ptr_t<Smart, P, Args&&...>(s, std::forward<Args>(args)...)`.
179
 
180
  #### Class template `inout_ptr_t` <a id="inout.ptr.t">[[inout.ptr.t]]</a>
181
 
182
  `inout_ptr_t` is a class template used to adapt types such as smart
183
  pointers [[smartptr]] for functions that use output pointer parameters
 
217
  ``` cpp
218
  namespace std {
219
  template<class Smart, class Pointer, class... Args>
220
  class inout_ptr_t {
221
  public:
222
+ constexpr explicit inout_ptr_t(Smart&, Args...);
223
  inout_ptr_t(const inout_ptr_t&) = delete;
224
 
225
+ constexpr ~inout_ptr_t();
226
 
227
+ constexpr operator Pointer*() const noexcept;
228
  operator void**() const noexcept;
229
 
230
  private:
231
  Smart& s; // exposition only
232
  tuple<Args...> a; // exposition only
 
248
 
249
  Evaluations of the conversion functions on the same object may conflict
250
  [[intro.races]].
251
 
252
  ``` cpp
253
+ constexpr explicit inout_ptr_t(Smart& smart, Args... args);
254
  ```
255
 
256
  *Effects:* Initializes `s` with `smart`, `a` with
257
  `std::forward<Args>(args)...`, and `p` to either
258
 
 
265
  non-terminating and safe implementation strategies. For example, an
266
  intrusive pointer implementation with a control block can allocate in
267
  the constructor and safely fail with an exception. — *end note*]
268
 
269
  ``` cpp
270
+ constexpr ~inout_ptr_t();
271
  ```
272
 
273
  Let `SP` be *`POINTER_OF_OR`*`(Smart, Pointer)` [[memory.general]].
274
 
275
  Let *release-statement* be `s.release();` if an implementation does not
 
277
 
278
  *Effects:* Equivalent to:
279
 
280
  -
281
  ``` cpp
 
282
  apply([&](auto&&... args) {
283
  s = Smart(static_cast<SP>(p), std::forward<Args>(args)...); }, std::move(a));
 
284
  ```
285
 
286
  if `is_pointer_v<Smart>` is `true`;
287
  - otherwise,
288
  ``` cpp
 
307
 
308
  if `is_constructible_v<Smart, SP, Args...>` is `true`;
309
  - otherwise, the program is ill-formed.
310
 
311
  ``` cpp
312
+ constexpr operator Pointer*() const noexcept;
313
  ```
314
 
315
  *Preconditions:* `operator void**()` has not been called on `*this`.
316
 
317
  *Returns:* `addressof(const_cast<Pointer&>(p))`.
 
342
 
343
  #### Function template `inout_ptr` <a id="inout.ptr">[[inout.ptr]]</a>
344
 
345
  ``` cpp
346
  template<class Pointer = void, class Smart, class... Args>
347
+ constexpr auto inout_ptr(Smart& s, Args&&... args);
348
  ```
349
 
350
  Let `P` be `Pointer` if `is_void_v<Pointer>` is `false`, otherwise
351
  *`POINTER_OF`*`(Smart)`.
352