tmp/tmpv_bp4jra/{from.md → to.md}
RENAMED
|
@@ -2,41 +2,44 @@
|
|
| 2 |
|
| 3 |
``` cpp
|
| 4 |
namespace std {
|
| 5 |
template <class T, class D> class unique_ptr<T[], D> {
|
| 6 |
public:
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
|
| 11 |
// [unique.ptr.runtime.ctor], constructors
|
| 12 |
constexpr unique_ptr() noexcept;
|
| 13 |
-
explicit unique_ptr(
|
| 14 |
-
unique_ptr(
|
| 15 |
-
unique_ptr(
|
| 16 |
unique_ptr(unique_ptr&& u) noexcept;
|
| 17 |
-
|
|
|
|
|
|
|
| 18 |
|
| 19 |
// destructor
|
| 20 |
~unique_ptr();
|
| 21 |
|
| 22 |
// assignment
|
| 23 |
unique_ptr& operator=(unique_ptr&& u) noexcept;
|
|
|
|
|
|
|
| 24 |
unique_ptr& operator=(nullptr_t) noexcept;
|
| 25 |
|
| 26 |
// [unique.ptr.runtime.observers], observers
|
| 27 |
T& operator[](size_t i) const;
|
| 28 |
pointer get() const noexcept;
|
| 29 |
deleter_type& get_deleter() noexcept;
|
| 30 |
const deleter_type& get_deleter() const noexcept;
|
| 31 |
explicit operator bool() const noexcept;
|
| 32 |
|
| 33 |
-
// [unique.ptr.runtime.modifiers] modifiers
|
| 34 |
pointer release() noexcept;
|
| 35 |
-
void reset(
|
| 36 |
-
void reset(nullptr_t) noexcept;
|
| 37 |
-
template <class U> void reset(U) = delete;
|
| 38 |
void swap(unique_ptr& u) noexcept;
|
| 39 |
|
| 40 |
// disable copy from lvalue
|
| 41 |
unique_ptr(const unique_ptr&) = delete;
|
| 42 |
unique_ptr& operator=(const unique_ptr&) = delete;
|
|
@@ -45,36 +48,92 @@ namespace std {
|
|
| 45 |
```
|
| 46 |
|
| 47 |
A specialization for array types is provided with a slightly altered
|
| 48 |
interface.
|
| 49 |
|
| 50 |
-
- Conversions between different types of `unique_ptr<T[], D>`
|
| 51 |
-
|
| 52 |
-
|
|
|
|
| 53 |
- Pointers to types derived from `T` are rejected by the constructors,
|
| 54 |
and by `reset`.
|
| 55 |
- The observers `operator*` and `operator->` are not provided.
|
| 56 |
- The indexing observer `operator[]` is provided.
|
| 57 |
- The default deleter will call `delete[]`.
|
| 58 |
|
| 59 |
-
Descriptions are provided below only for
|
| 60 |
-
|
| 61 |
|
| 62 |
The template argument `T` shall be a complete type.
|
| 63 |
|
| 64 |
##### `unique_ptr` constructors <a id="unique.ptr.runtime.ctor">[[unique.ptr.runtime.ctor]]</a>
|
| 65 |
|
| 66 |
``` cpp
|
| 67 |
-
explicit unique_ptr(
|
| 68 |
-
unique_ptr(pointer p, see below d) noexcept;
|
| 69 |
-
unique_ptr(pointer p, see below d) noexcept;
|
| 70 |
```
|
| 71 |
|
| 72 |
-
|
| 73 |
-
that
|
| 74 |
-
|
| 75 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 76 |
|
| 77 |
##### `unique_ptr` observers <a id="unique.ptr.runtime.observers">[[unique.ptr.runtime.observers]]</a>
|
| 78 |
|
| 79 |
``` cpp
|
| 80 |
T& operator[](size_t i) const;
|
|
@@ -86,10 +145,22 @@ stored pointer points.
|
|
| 86 |
*Returns:* `get()[i]`.
|
| 87 |
|
| 88 |
##### `unique_ptr` modifiers <a id="unique.ptr.runtime.modifiers">[[unique.ptr.runtime.modifiers]]</a>
|
| 89 |
|
| 90 |
``` cpp
|
| 91 |
-
void reset(nullptr_t p) noexcept;
|
| 92 |
```
|
| 93 |
|
| 94 |
*Effects:* Equivalent to `reset(pointer())`.
|
| 95 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2 |
|
| 3 |
``` cpp
|
| 4 |
namespace std {
|
| 5 |
template <class T, class D> class unique_ptr<T[], D> {
|
| 6 |
public:
|
| 7 |
+
using pointer = see below;
|
| 8 |
+
using element_type = T;
|
| 9 |
+
using deleter_type = D;
|
| 10 |
|
| 11 |
// [unique.ptr.runtime.ctor], constructors
|
| 12 |
constexpr unique_ptr() noexcept;
|
| 13 |
+
template <class U> explicit unique_ptr(U p) noexcept;
|
| 14 |
+
template <class U> unique_ptr(U p, see below d) noexcept;
|
| 15 |
+
template <class U> unique_ptr(U p, see below d) noexcept;
|
| 16 |
unique_ptr(unique_ptr&& u) noexcept;
|
| 17 |
+
template <class U, class E>
|
| 18 |
+
unique_ptr(unique_ptr<U, E>&& u) noexcept;
|
| 19 |
+
constexpr unique_ptr(nullptr_t) noexcept;
|
| 20 |
|
| 21 |
// destructor
|
| 22 |
~unique_ptr();
|
| 23 |
|
| 24 |
// assignment
|
| 25 |
unique_ptr& operator=(unique_ptr&& u) noexcept;
|
| 26 |
+
template <class U, class E>
|
| 27 |
+
unique_ptr& operator=(unique_ptr<U, E>&& u) noexcept;
|
| 28 |
unique_ptr& operator=(nullptr_t) noexcept;
|
| 29 |
|
| 30 |
// [unique.ptr.runtime.observers], observers
|
| 31 |
T& operator[](size_t i) const;
|
| 32 |
pointer get() const noexcept;
|
| 33 |
deleter_type& get_deleter() noexcept;
|
| 34 |
const deleter_type& get_deleter() const noexcept;
|
| 35 |
explicit operator bool() const noexcept;
|
| 36 |
|
| 37 |
+
// [unique.ptr.runtime.modifiers], modifiers
|
| 38 |
pointer release() noexcept;
|
| 39 |
+
template <class U> void reset(U p) noexcept;
|
| 40 |
+
void reset(nullptr_t = nullptr) noexcept;
|
|
|
|
| 41 |
void swap(unique_ptr& u) noexcept;
|
| 42 |
|
| 43 |
// disable copy from lvalue
|
| 44 |
unique_ptr(const unique_ptr&) = delete;
|
| 45 |
unique_ptr& operator=(const unique_ptr&) = delete;
|
|
|
|
| 48 |
```
|
| 49 |
|
| 50 |
A specialization for array types is provided with a slightly altered
|
| 51 |
interface.
|
| 52 |
|
| 53 |
+
- Conversions between different types of `unique_ptr<T[], D>` that would
|
| 54 |
+
be disallowed for the corresponding pointer-to-array types, and
|
| 55 |
+
conversions to or from the non-array forms of `unique_ptr`, produce an
|
| 56 |
+
ill-formed program.
|
| 57 |
- Pointers to types derived from `T` are rejected by the constructors,
|
| 58 |
and by `reset`.
|
| 59 |
- The observers `operator*` and `operator->` are not provided.
|
| 60 |
- The indexing observer `operator[]` is provided.
|
| 61 |
- The default deleter will call `delete[]`.
|
| 62 |
|
| 63 |
+
Descriptions are provided below only for members that differ from the
|
| 64 |
+
primary template.
|
| 65 |
|
| 66 |
The template argument `T` shall be a complete type.
|
| 67 |
|
| 68 |
##### `unique_ptr` constructors <a id="unique.ptr.runtime.ctor">[[unique.ptr.runtime.ctor]]</a>
|
| 69 |
|
| 70 |
``` cpp
|
| 71 |
+
template <class U> explicit unique_ptr(U p) noexcept;
|
|
|
|
|
|
|
| 72 |
```
|
| 73 |
|
| 74 |
+
This constructor behaves the same as the constructor in the primary
|
| 75 |
+
template that takes a single parameter of type `pointer` except that it
|
| 76 |
+
additionally shall not participate in overload resolution unless
|
| 77 |
+
|
| 78 |
+
- `U` is the same type as `pointer`, or
|
| 79 |
+
- `pointer` is the same type as `element_type*`, `U` is a pointer type
|
| 80 |
+
`V*`, and `V(*)[]` is convertible to `element_type(*)[]`.
|
| 81 |
+
|
| 82 |
+
``` cpp
|
| 83 |
+
template <class U> unique_ptr(U p, see below d) noexcept;
|
| 84 |
+
template <class U> unique_ptr(U p, see below d) noexcept;
|
| 85 |
+
```
|
| 86 |
+
|
| 87 |
+
These constructors behave the same as the constructors in the primary
|
| 88 |
+
template that take a parameter of type `pointer` and a second parameter
|
| 89 |
+
except that they shall not participate in overload resolution unless
|
| 90 |
+
either
|
| 91 |
+
|
| 92 |
+
- `U` is the same type as `pointer`,
|
| 93 |
+
- `U` is `nullptr_t`, or
|
| 94 |
+
- `pointer` is the same type as `element_type*`, `U` is a pointer type
|
| 95 |
+
`V*`, and `V(*)[]` is convertible to `element_type(*)[]`.
|
| 96 |
+
|
| 97 |
+
``` cpp
|
| 98 |
+
template <class U, class E>
|
| 99 |
+
unique_ptr(unique_ptr<U, E>&& u) noexcept;
|
| 100 |
+
```
|
| 101 |
+
|
| 102 |
+
This constructor behaves the same as in the primary template, except
|
| 103 |
+
that it shall not participate in overload resolution unless all of the
|
| 104 |
+
following conditions hold, where `UP` is `unique_ptr<U, E>`:
|
| 105 |
+
|
| 106 |
+
- `U` is an array type, and
|
| 107 |
+
- `pointer` is the same type as `element_type*`, and
|
| 108 |
+
- `UP::pointer` is the same type as `UP::element_type*`, and
|
| 109 |
+
- `UP::element_type(*)[]` is convertible to `element_type(*)[]`, and
|
| 110 |
+
- either `D` is a reference type and `E` is the same type as `D`, or `D`
|
| 111 |
+
is not a reference type and `E` is implicitly convertible to `D`.
|
| 112 |
+
|
| 113 |
+
[*Note 1*: This replaces the overload-resolution specification of the
|
| 114 |
+
primary template — *end note*]
|
| 115 |
+
|
| 116 |
+
##### `unique_ptr` assignment <a id="unique.ptr.runtime.asgn">[[unique.ptr.runtime.asgn]]</a>
|
| 117 |
+
|
| 118 |
+
``` cpp
|
| 119 |
+
template <class U, class E>
|
| 120 |
+
unique_ptr& operator=(unique_ptr<U, E>&& u)noexcept;
|
| 121 |
+
```
|
| 122 |
+
|
| 123 |
+
This operator behaves the same as in the primary template, except that
|
| 124 |
+
it shall not participate in overload resolution unless all of the
|
| 125 |
+
following conditions hold, where `UP` is `unique_ptr<U, E>`:
|
| 126 |
+
|
| 127 |
+
- `U` is an array type, and
|
| 128 |
+
- `pointer` is the same type as `element_type*`, and
|
| 129 |
+
- `UP::pointer` is the same type as `UP::element_type*`, and
|
| 130 |
+
- `UP::element_type(*)[]` is convertible to `element_type(*)[]`, and
|
| 131 |
+
- `is_assignable_v<D&, E&&>` is `true`.
|
| 132 |
+
|
| 133 |
+
[*Note 2*: This replaces the overload-resolution specification of the
|
| 134 |
+
primary template — *end note*]
|
| 135 |
|
| 136 |
##### `unique_ptr` observers <a id="unique.ptr.runtime.observers">[[unique.ptr.runtime.observers]]</a>
|
| 137 |
|
| 138 |
``` cpp
|
| 139 |
T& operator[](size_t i) const;
|
|
|
|
| 145 |
*Returns:* `get()[i]`.
|
| 146 |
|
| 147 |
##### `unique_ptr` modifiers <a id="unique.ptr.runtime.modifiers">[[unique.ptr.runtime.modifiers]]</a>
|
| 148 |
|
| 149 |
``` cpp
|
| 150 |
+
void reset(nullptr_t p = nullptr) noexcept;
|
| 151 |
```
|
| 152 |
|
| 153 |
*Effects:* Equivalent to `reset(pointer())`.
|
| 154 |
|
| 155 |
+
``` cpp
|
| 156 |
+
template <class U> void reset(U p) noexcept;
|
| 157 |
+
```
|
| 158 |
+
|
| 159 |
+
This function behaves the same as the `reset` member of the primary
|
| 160 |
+
template, except that it shall not participate in overload resolution
|
| 161 |
+
unless either
|
| 162 |
+
|
| 163 |
+
- `U` is the same type as `pointer`, or
|
| 164 |
+
- `pointer` is the same type as `element_type*`, `U` is a pointer type
|
| 165 |
+
`V*`, and `V(*)[]` is convertible to `element_type(*)[]`.
|
| 166 |
+
|