tmp/tmpmhj5ouqy/{from.md → to.md}
RENAMED
|
@@ -0,0 +1,31 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#### General <a id="unique.ptr.general">[[unique.ptr.general]]</a>
|
| 2 |
+
|
| 3 |
+
A *unique pointer* is an object that owns another object and manages
|
| 4 |
+
that other object through a pointer. More precisely, a unique pointer is
|
| 5 |
+
an object *u* that stores a pointer to a second object *p* and will
|
| 6 |
+
dispose of *p* when *u* is itself destroyed (e.g., when leaving block
|
| 7 |
+
scope [[stmt.dcl]]). In this context, *u* is said to *own* `p`.
|
| 8 |
+
|
| 9 |
+
The mechanism by which *u* disposes of *p* is known as *p*’s associated
|
| 10 |
+
*deleter*, a function object whose correct invocation results in *p*’s
|
| 11 |
+
appropriate disposition (typically its deletion).
|
| 12 |
+
|
| 13 |
+
Let the notation *u.p* denote the pointer stored by *u*, and let *u.d*
|
| 14 |
+
denote the associated deleter. Upon request, *u* can *reset* (replace)
|
| 15 |
+
*u.p* and *u.d* with another pointer and deleter, but properly disposes
|
| 16 |
+
of its owned object via the associated deleter before such replacement
|
| 17 |
+
is considered completed.
|
| 18 |
+
|
| 19 |
+
Each object of a type `U` instantiated from the `unique_ptr` template
|
| 20 |
+
specified in [[unique.ptr]] has the strict ownership semantics,
|
| 21 |
+
specified above, of a unique pointer. In partial satisfaction of these
|
| 22 |
+
semantics, each such `U` is *Cpp17MoveConstructible* and
|
| 23 |
+
*Cpp17MoveAssignable*, but is not *Cpp17CopyConstructible* nor
|
| 24 |
+
*Cpp17CopyAssignable*. The template parameter `T` of `unique_ptr` may be
|
| 25 |
+
an incomplete type.
|
| 26 |
+
|
| 27 |
+
[*Note 1*: The uses of `unique_ptr` include providing exception safety
|
| 28 |
+
for dynamically allocated memory, passing ownership of dynamically
|
| 29 |
+
allocated memory to a function, and returning dynamically allocated
|
| 30 |
+
memory from a function. — *end note*]
|
| 31 |
+
|