tmp/tmp6zz4oi8f/{from.md → to.md}
RENAMED
|
@@ -6,26 +6,26 @@ unambiguous and accessible base class that is a specialization of
|
|
| 6 |
`enable_shared_from_this` [[util.smartptr.enab]], then `remove_cv_t<Y>*`
|
| 7 |
shall be implicitly convertible to `T*` and the constructor evaluates
|
| 8 |
the statement:
|
| 9 |
|
| 10 |
``` cpp
|
| 11 |
-
if (p != nullptr && p->
|
| 12 |
-
p->
|
| 13 |
```
|
| 14 |
|
| 15 |
-
The assignment to the `
|
| 16 |
with any potentially concurrent access to the same object
|
| 17 |
[[intro.multithread]].
|
| 18 |
|
| 19 |
``` cpp
|
| 20 |
constexpr shared_ptr() noexcept;
|
| 21 |
```
|
| 22 |
|
| 23 |
*Ensures:* `use_count() == 0 && get() == nullptr`.
|
| 24 |
|
| 25 |
``` cpp
|
| 26 |
-
template<class Y> explicit shared_ptr(Y* p);
|
| 27 |
```
|
| 28 |
|
| 29 |
*Constraints:* When `T` is an array type, the expression `delete[] p` is
|
| 30 |
well-formed and either `T` is `U[N]` and `Y(*)[N]` is convertible to
|
| 31 |
`T*`, or `T` is `U[]` and `Y(*)[]` is convertible to `T*`. When `T` is
|
|
@@ -49,14 +49,14 @@ not an array type, `delete[] p` otherwise.
|
|
| 49 |
|
| 50 |
*Throws:* `bad_alloc`, or an *implementation-defined* exception when a
|
| 51 |
resource other than memory cannot be obtained.
|
| 52 |
|
| 53 |
``` cpp
|
| 54 |
-
template<class Y, class D> shared_ptr(Y* p, D d);
|
| 55 |
-
template<class Y, class D, class A> shared_ptr(Y* p, D d, A a);
|
| 56 |
-
template<class D> shared_ptr(nullptr_t p, D d);
|
| 57 |
-
template<class D, class A> shared_ptr(nullptr_t p, D d, A a);
|
| 58 |
```
|
| 59 |
|
| 60 |
*Constraints:* `is_move_constructible_v<D>` is `true`, and `d(p)` is a
|
| 61 |
well-formed expression. For the first two overloads:
|
| 62 |
|
|
@@ -81,12 +81,12 @@ use. If an exception is thrown, `d(p)` is called.
|
|
| 81 |
|
| 82 |
*Throws:* `bad_alloc`, or an *implementation-defined* exception when a
|
| 83 |
resource other than memory cannot be obtained.
|
| 84 |
|
| 85 |
``` cpp
|
| 86 |
-
template<class Y> shared_ptr(const shared_ptr<Y>& r, element_type* p) noexcept;
|
| 87 |
-
template<class Y> shared_ptr(shared_ptr<Y>&& r, element_type* p) noexcept;
|
| 88 |
```
|
| 89 |
|
| 90 |
*Effects:* Constructs a `shared_ptr` instance that stores `p` and shares
|
| 91 |
ownership with the initial value of `r`.
|
| 92 |
|
|
@@ -99,12 +99,12 @@ destroyed. — *end note*]
|
|
| 99 |
|
| 100 |
[*Note 2*: This constructor allows creation of an empty `shared_ptr`
|
| 101 |
instance with a non-null stored pointer. — *end note*]
|
| 102 |
|
| 103 |
``` cpp
|
| 104 |
-
shared_ptr(const shared_ptr& r) noexcept;
|
| 105 |
-
template<class Y> shared_ptr(const shared_ptr<Y>& r) noexcept;
|
| 106 |
```
|
| 107 |
|
| 108 |
*Constraints:* For the second constructor, `Y*` is compatible with `T*`.
|
| 109 |
|
| 110 |
*Effects:* If `r` is empty, constructs an empty `shared_ptr` object;
|
|
@@ -112,23 +112,23 @@ otherwise, constructs a `shared_ptr` object that shares ownership with
|
|
| 112 |
`r`.
|
| 113 |
|
| 114 |
*Ensures:* `get() == r.get() && use_count() == r.use_count()`.
|
| 115 |
|
| 116 |
``` cpp
|
| 117 |
-
shared_ptr(shared_ptr&& r) noexcept;
|
| 118 |
-
template<class Y> shared_ptr(shared_ptr<Y>&& r) noexcept;
|
| 119 |
```
|
| 120 |
|
| 121 |
*Constraints:* For the second constructor, `Y*` is compatible with `T*`.
|
| 122 |
|
| 123 |
*Effects:* Move constructs a `shared_ptr` instance from `r`.
|
| 124 |
|
| 125 |
*Ensures:* `*this` contains the old value of `r`. `r` is empty, and
|
| 126 |
`r.get() == nullptr`.
|
| 127 |
|
| 128 |
``` cpp
|
| 129 |
-
template<class Y> explicit shared_ptr(const weak_ptr<Y>& r);
|
| 130 |
```
|
| 131 |
|
| 132 |
*Constraints:* `Y*` is compatible with `T*`.
|
| 133 |
|
| 134 |
*Effects:* Constructs a `shared_ptr` object that shares ownership with
|
|
@@ -138,11 +138,11 @@ thrown, the constructor has no effect.
|
|
| 138 |
*Ensures:* `use_count() == r.use_count()`.
|
| 139 |
|
| 140 |
*Throws:* `bad_weak_ptr` when `r.expired()`.
|
| 141 |
|
| 142 |
``` cpp
|
| 143 |
-
template<class Y, class D> shared_ptr(unique_ptr<Y, D>&& r);
|
| 144 |
```
|
| 145 |
|
| 146 |
*Constraints:* `Y*` is compatible with `T*` and
|
| 147 |
`unique_ptr<Y, D>::pointer` is convertible to `element_type*`.
|
| 148 |
|
|
|
|
| 6 |
`enable_shared_from_this` [[util.smartptr.enab]], then `remove_cv_t<Y>*`
|
| 7 |
shall be implicitly convertible to `T*` and the constructor evaluates
|
| 8 |
the statement:
|
| 9 |
|
| 10 |
``` cpp
|
| 11 |
+
if (p != nullptr && p->weak-this.expired())
|
| 12 |
+
p->weak-this = shared_ptr<remove_cv_t<Y>>(*this, const_cast<remove_cv_t<Y>*>(p));
|
| 13 |
```
|
| 14 |
|
| 15 |
+
The assignment to the *`weak-this`* member is not atomic and conflicts
|
| 16 |
with any potentially concurrent access to the same object
|
| 17 |
[[intro.multithread]].
|
| 18 |
|
| 19 |
``` cpp
|
| 20 |
constexpr shared_ptr() noexcept;
|
| 21 |
```
|
| 22 |
|
| 23 |
*Ensures:* `use_count() == 0 && get() == nullptr`.
|
| 24 |
|
| 25 |
``` cpp
|
| 26 |
+
template<class Y> constexpr explicit shared_ptr(Y* p);
|
| 27 |
```
|
| 28 |
|
| 29 |
*Constraints:* When `T` is an array type, the expression `delete[] p` is
|
| 30 |
well-formed and either `T` is `U[N]` and `Y(*)[N]` is convertible to
|
| 31 |
`T*`, or `T` is `U[]` and `Y(*)[]` is convertible to `T*`. When `T` is
|
|
|
|
| 49 |
|
| 50 |
*Throws:* `bad_alloc`, or an *implementation-defined* exception when a
|
| 51 |
resource other than memory cannot be obtained.
|
| 52 |
|
| 53 |
``` cpp
|
| 54 |
+
template<class Y, class D> constexpr shared_ptr(Y* p, D d);
|
| 55 |
+
template<class Y, class D, class A> constexpr shared_ptr(Y* p, D d, A a);
|
| 56 |
+
template<class D> constexpr shared_ptr(nullptr_t p, D d);
|
| 57 |
+
template<class D, class A> constexpr shared_ptr(nullptr_t p, D d, A a);
|
| 58 |
```
|
| 59 |
|
| 60 |
*Constraints:* `is_move_constructible_v<D>` is `true`, and `d(p)` is a
|
| 61 |
well-formed expression. For the first two overloads:
|
| 62 |
|
|
|
|
| 81 |
|
| 82 |
*Throws:* `bad_alloc`, or an *implementation-defined* exception when a
|
| 83 |
resource other than memory cannot be obtained.
|
| 84 |
|
| 85 |
``` cpp
|
| 86 |
+
template<class Y> constexpr shared_ptr(const shared_ptr<Y>& r, element_type* p) noexcept;
|
| 87 |
+
template<class Y> constexpr shared_ptr(shared_ptr<Y>&& r, element_type* p) noexcept;
|
| 88 |
```
|
| 89 |
|
| 90 |
*Effects:* Constructs a `shared_ptr` instance that stores `p` and shares
|
| 91 |
ownership with the initial value of `r`.
|
| 92 |
|
|
|
|
| 99 |
|
| 100 |
[*Note 2*: This constructor allows creation of an empty `shared_ptr`
|
| 101 |
instance with a non-null stored pointer. — *end note*]
|
| 102 |
|
| 103 |
``` cpp
|
| 104 |
+
constexpr shared_ptr(const shared_ptr& r) noexcept;
|
| 105 |
+
template<class Y> constexpr shared_ptr(const shared_ptr<Y>& r) noexcept;
|
| 106 |
```
|
| 107 |
|
| 108 |
*Constraints:* For the second constructor, `Y*` is compatible with `T*`.
|
| 109 |
|
| 110 |
*Effects:* If `r` is empty, constructs an empty `shared_ptr` object;
|
|
|
|
| 112 |
`r`.
|
| 113 |
|
| 114 |
*Ensures:* `get() == r.get() && use_count() == r.use_count()`.
|
| 115 |
|
| 116 |
``` cpp
|
| 117 |
+
constexpr shared_ptr(shared_ptr&& r) noexcept;
|
| 118 |
+
template<class Y> constexpr shared_ptr(shared_ptr<Y>&& r) noexcept;
|
| 119 |
```
|
| 120 |
|
| 121 |
*Constraints:* For the second constructor, `Y*` is compatible with `T*`.
|
| 122 |
|
| 123 |
*Effects:* Move constructs a `shared_ptr` instance from `r`.
|
| 124 |
|
| 125 |
*Ensures:* `*this` contains the old value of `r`. `r` is empty, and
|
| 126 |
`r.get() == nullptr`.
|
| 127 |
|
| 128 |
``` cpp
|
| 129 |
+
template<class Y> constexpr explicit shared_ptr(const weak_ptr<Y>& r);
|
| 130 |
```
|
| 131 |
|
| 132 |
*Constraints:* `Y*` is compatible with `T*`.
|
| 133 |
|
| 134 |
*Effects:* Constructs a `shared_ptr` object that shares ownership with
|
|
|
|
| 138 |
*Ensures:* `use_count() == r.use_count()`.
|
| 139 |
|
| 140 |
*Throws:* `bad_weak_ptr` when `r.expired()`.
|
| 141 |
|
| 142 |
``` cpp
|
| 143 |
+
template<class Y, class D> constexpr shared_ptr(unique_ptr<Y, D>&& r);
|
| 144 |
```
|
| 145 |
|
| 146 |
*Constraints:* `Y*` is compatible with `T*` and
|
| 147 |
`unique_ptr<Y, D>::pointer` is convertible to `element_type*`.
|
| 148 |
|