tmp/tmpe_dqacji/{from.md → to.md}
RENAMED
|
@@ -5,17 +5,17 @@ The common requirements that apply to all `make_shared`,
|
|
| 5 |
`allocate_shared_for_overwrite` overloads, unless specified otherwise,
|
| 6 |
are described below.
|
| 7 |
|
| 8 |
``` cpp
|
| 9 |
template<class T, ...>
|
| 10 |
-
shared_ptr<T> make_shared(args);
|
| 11 |
template<class T, class A, ...>
|
| 12 |
-
shared_ptr<T> allocate_shared(const A& a, args);
|
| 13 |
template<class T, ...>
|
| 14 |
-
shared_ptr<T> make_shared_for_overwrite(args);
|
| 15 |
template<class T, class A, ...>
|
| 16 |
-
shared_ptr<T> allocate_shared_for_overwrite(const A& a, args);
|
| 17 |
```
|
| 18 |
|
| 19 |
*Preconditions:* `A` meets the *Cpp17Allocator*
|
| 20 |
requirements [[allocator.requirements.general]].
|
| 21 |
|
|
@@ -56,56 +56,58 @@ the initialization of the object.
|
|
| 56 |
suitable to hold an object of type `U`.
|
| 57 |
- When a (sub)object of a non-array type `U` is specified to have an
|
| 58 |
initial value of `v`, or `U(l...)`, where `l...` is a list of
|
| 59 |
constructor arguments, `allocate_shared` shall initialize this
|
| 60 |
(sub)object via the expression
|
| 61 |
-
- `allocator_traits<A2>::construct(a2,
|
| 62 |
-
- `allocator_traits<A2>::construct(a2,
|
| 63 |
|
| 64 |
-
respectively, where `
|
| 65 |
-
|
| 66 |
-
`
|
| 67 |
-
`
|
| 68 |
- When a (sub)object of non-array type `U` is specified to have a
|
| 69 |
default initial value, `make_shared` shall initialize this (sub)object
|
| 70 |
via the expression `::new(pv) U()`, where `pv` has type `void*` and
|
| 71 |
points to storage suitable to hold an object of type `U`.
|
| 72 |
- When a (sub)object of non-array type `U` is specified to have a
|
| 73 |
-
default initial value, `allocate_shared`
|
| 74 |
-
|
| 75 |
-
`
|
| 76 |
-
|
| 77 |
-
is a rebound copy of the allocator `a` passed to
|
| 78 |
-
|
| 79 |
- When a (sub)object of non-array type `U` is initialized by
|
| 80 |
`make_shared_for_overwrite` or `allocate_shared_for_overwrite`, it is
|
| 81 |
initialized via the expression `::new(pv) U`, where `pv` has type
|
| 82 |
`void*` and points to storage suitable to hold an object of type `U`.
|
| 83 |
- Array elements are initialized in ascending order of their addresses.
|
| 84 |
- When the lifetime of the object managed by the return value ends, or
|
| 85 |
when the initialization of an array element throws an exception, the
|
| 86 |
initialized elements are destroyed in the reverse order of their
|
| 87 |
original construction.
|
| 88 |
- When a (sub)object of non-array type `U` that was initialized by
|
| 89 |
-
`make_shared`
|
| 90 |
-
`
|
|
|
|
|
|
|
| 91 |
- When a (sub)object of non-array type `U` that was initialized by
|
| 92 |
`allocate_shared` is to be destroyed, it is destroyed via the
|
| 93 |
-
expression `allocator_traits<A2>::destroy(a2,
|
| 94 |
-
|
| 95 |
-
|
| 96 |
-
|
| 97 |
|
| 98 |
[*Note 7*: These functions will typically allocate more memory than
|
| 99 |
`sizeof(T)` to allow for internal bookkeeping structures such as
|
| 100 |
reference counts. — *end note*]
|
| 101 |
|
| 102 |
``` cpp
|
| 103 |
template<class T, class... Args>
|
| 104 |
-
shared_ptr<T> make_shared(Args&&... args); // T is not array
|
| 105 |
template<class T, class A, class... Args>
|
| 106 |
-
shared_ptr<T> allocate_shared(const A& a, Args&&... args); // T is not array
|
| 107 |
```
|
| 108 |
|
| 109 |
*Constraints:* `T` is not an array type.
|
| 110 |
|
| 111 |
*Returns:* A `shared_ptr` to an object of type `T` with an initial value
|
|
@@ -124,14 +126,14 @@ shared_ptr<vector<int>> q = make_shared<vector<int>>(16, 1);
|
|
| 124 |
```
|
| 125 |
|
| 126 |
— *end example*]
|
| 127 |
|
| 128 |
``` cpp
|
| 129 |
-
template<class T>
|
| 130 |
-
make_shared(size_t N);
|
| 131 |
template<class T, class A>
|
| 132 |
-
shared_ptr<T> allocate_shared(const A& a, size_t N); // T is U[]
|
| 133 |
```
|
| 134 |
|
| 135 |
*Constraints:* `T` is of the form `U[]`.
|
| 136 |
|
| 137 |
*Returns:* A `shared_ptr` to an object of type `U[N]` with a default
|
|
@@ -148,13 +150,13 @@ shared_ptr<double[][2][2]> q = make_shared<double[][2][2]>(6);
|
|
| 148 |
|
| 149 |
— *end example*]
|
| 150 |
|
| 151 |
``` cpp
|
| 152 |
template<class T>
|
| 153 |
-
shared_ptr<T> make_shared(); // T is U[N]
|
| 154 |
template<class T, class A>
|
| 155 |
-
shared_ptr<T> allocate_shared(const A& a); // T is U[N]
|
| 156 |
```
|
| 157 |
|
| 158 |
*Constraints:* `T` is of the form `U[N]`.
|
| 159 |
|
| 160 |
*Returns:* A `shared_ptr` to an object of type `T` with a default
|
|
@@ -171,14 +173,14 @@ shared_ptr<double[6][2][2]> q = make_shared<double[6][2][2]>();
|
|
| 171 |
|
| 172 |
— *end example*]
|
| 173 |
|
| 174 |
``` cpp
|
| 175 |
template<class T>
|
| 176 |
-
shared_ptr<T> make_shared(size_t N,
|
| 177 |
const remove_extent_t<T>& u); // T is U[]
|
| 178 |
template<class T, class A>
|
| 179 |
-
shared_ptr<T> allocate_shared(const A& a, size_t N,
|
| 180 |
const remove_extent_t<T>& u); // T is U[]
|
| 181 |
```
|
| 182 |
|
| 183 |
*Constraints:* `T` is of the form `U[]`.
|
| 184 |
|
|
@@ -198,13 +200,13 @@ shared_ptr<vector<int>[]> r = make_shared<vector<int>[]>(4, {1, 2});
|
|
| 198 |
|
| 199 |
— *end example*]
|
| 200 |
|
| 201 |
``` cpp
|
| 202 |
template<class T>
|
| 203 |
-
shared_ptr<T> make_shared(const remove_extent_t<T>& u); // T is U[N]
|
| 204 |
template<class T, class A>
|
| 205 |
-
shared_ptr<T> allocate_shared(const A& a,
|
| 206 |
const remove_extent_t<T>& u); // T is U[N]
|
| 207 |
```
|
| 208 |
|
| 209 |
*Constraints:* `T` is of the form `U[N]`.
|
| 210 |
|
|
@@ -224,13 +226,13 @@ shared_ptr<vector<int>[4]> r = make_shared<vector<int>[4]>({1, 2});
|
|
| 224 |
|
| 225 |
— *end example*]
|
| 226 |
|
| 227 |
``` cpp
|
| 228 |
template<class T>
|
| 229 |
-
shared_ptr<T> make_shared_for_overwrite();
|
| 230 |
template<class T, class A>
|
| 231 |
-
shared_ptr<T> allocate_shared_for_overwrite(const A& a);
|
| 232 |
```
|
| 233 |
|
| 234 |
*Constraints:* `T` is not an array of unknown bound.
|
| 235 |
|
| 236 |
*Returns:* A `shared_ptr` to an object of type `T`.
|
|
@@ -248,13 +250,13 @@ shared_ptr<double[1024]> q = make_shared_for_overwrite<double[1024]>();
|
|
| 248 |
|
| 249 |
— *end example*]
|
| 250 |
|
| 251 |
``` cpp
|
| 252 |
template<class T>
|
| 253 |
-
shared_ptr<T> make_shared_for_overwrite(size_t N);
|
| 254 |
template<class T, class A>
|
| 255 |
-
shared_ptr<T> allocate_shared_for_overwrite(const A& a, size_t N);
|
| 256 |
```
|
| 257 |
|
| 258 |
*Constraints:* `T` is an array of unknown bound.
|
| 259 |
|
| 260 |
*Returns:* A `shared_ptr` to an object of type `U[N]`, where `U` is
|
|
|
|
| 5 |
`allocate_shared_for_overwrite` overloads, unless specified otherwise,
|
| 6 |
are described below.
|
| 7 |
|
| 8 |
``` cpp
|
| 9 |
template<class T, ...>
|
| 10 |
+
constexpr shared_ptr<T> make_shared(args);
|
| 11 |
template<class T, class A, ...>
|
| 12 |
+
constexpr shared_ptr<T> allocate_shared(const A& a, args);
|
| 13 |
template<class T, ...>
|
| 14 |
+
constexpr shared_ptr<T> make_shared_for_overwrite(args);
|
| 15 |
template<class T, class A, ...>
|
| 16 |
+
constexpr shared_ptr<T> allocate_shared_for_overwrite(const A& a, args);
|
| 17 |
```
|
| 18 |
|
| 19 |
*Preconditions:* `A` meets the *Cpp17Allocator*
|
| 20 |
requirements [[allocator.requirements.general]].
|
| 21 |
|
|
|
|
| 56 |
suitable to hold an object of type `U`.
|
| 57 |
- When a (sub)object of a non-array type `U` is specified to have an
|
| 58 |
initial value of `v`, or `U(l...)`, where `l...` is a list of
|
| 59 |
constructor arguments, `allocate_shared` shall initialize this
|
| 60 |
(sub)object via the expression
|
| 61 |
+
- `allocator_traits<A2>::construct(a2, pu, v)` or
|
| 62 |
+
- `allocator_traits<A2>::construct(a2, pu, l...)`
|
| 63 |
|
| 64 |
+
respectively, where `pu` is a pointer of type `remove_cv_t<U>*`
|
| 65 |
+
pointing to storage suitable to hold an object of type
|
| 66 |
+
`remove_cv_t<U>` and `a2` of type `A2` is a potentially rebound copy
|
| 67 |
+
of the allocator `a` passed to `allocate_shared`.
|
| 68 |
- When a (sub)object of non-array type `U` is specified to have a
|
| 69 |
default initial value, `make_shared` shall initialize this (sub)object
|
| 70 |
via the expression `::new(pv) U()`, where `pv` has type `void*` and
|
| 71 |
points to storage suitable to hold an object of type `U`.
|
| 72 |
- When a (sub)object of non-array type `U` is specified to have a
|
| 73 |
+
default initial value, `allocate_shared` initializes this (sub)object
|
| 74 |
+
via the expression `allocator_traits<A2>::construct(a2, pu)`, where
|
| 75 |
+
`pu` is a pointer of type `remove_cv_t<U>*` pointing to storage
|
| 76 |
+
suitable to hold an object of type `remove_cv_t<U>` and `a2` of type
|
| 77 |
+
`A2` is a potentially rebound copy of the allocator `a` passed to
|
| 78 |
+
`allocate_shared`.
|
| 79 |
- When a (sub)object of non-array type `U` is initialized by
|
| 80 |
`make_shared_for_overwrite` or `allocate_shared_for_overwrite`, it is
|
| 81 |
initialized via the expression `::new(pv) U`, where `pv` has type
|
| 82 |
`void*` and points to storage suitable to hold an object of type `U`.
|
| 83 |
- Array elements are initialized in ascending order of their addresses.
|
| 84 |
- When the lifetime of the object managed by the return value ends, or
|
| 85 |
when the initialization of an array element throws an exception, the
|
| 86 |
initialized elements are destroyed in the reverse order of their
|
| 87 |
original construction.
|
| 88 |
- When a (sub)object of non-array type `U` that was initialized by
|
| 89 |
+
`make_shared`, `make_shared_for_overwrite`, or
|
| 90 |
+
`allocate_shared_for_overwrite` is to be destroyed, it is destroyed
|
| 91 |
+
via the expression `pu->~U()` where `pu` points to that object of type
|
| 92 |
+
`U`.
|
| 93 |
- When a (sub)object of non-array type `U` that was initialized by
|
| 94 |
`allocate_shared` is to be destroyed, it is destroyed via the
|
| 95 |
+
expression `allocator_traits<A2>::destroy(a2, pu)` where `pu` is a
|
| 96 |
+
pointer of type `remove_cv_t<U>*` pointing to that object of type
|
| 97 |
+
`remove_cv_t<U>` and `a2` of type `A2` is a potentially rebound copy
|
| 98 |
+
of the allocator `a` passed to `allocate_shared`.
|
| 99 |
|
| 100 |
[*Note 7*: These functions will typically allocate more memory than
|
| 101 |
`sizeof(T)` to allow for internal bookkeeping structures such as
|
| 102 |
reference counts. — *end note*]
|
| 103 |
|
| 104 |
``` cpp
|
| 105 |
template<class T, class... Args>
|
| 106 |
+
constexpr shared_ptr<T> make_shared(Args&&... args); // T is not array
|
| 107 |
template<class T, class A, class... Args>
|
| 108 |
+
constexpr shared_ptr<T> allocate_shared(const A& a, Args&&... args); // T is not array
|
| 109 |
```
|
| 110 |
|
| 111 |
*Constraints:* `T` is not an array type.
|
| 112 |
|
| 113 |
*Returns:* A `shared_ptr` to an object of type `T` with an initial value
|
|
|
|
| 126 |
```
|
| 127 |
|
| 128 |
— *end example*]
|
| 129 |
|
| 130 |
``` cpp
|
| 131 |
+
template<class T>
|
| 132 |
+
constexpr shared_ptr<T> make_shared(size_t N); // T is U[]
|
| 133 |
template<class T, class A>
|
| 134 |
+
constexpr shared_ptr<T> allocate_shared(const A& a, size_t N); // T is U[]
|
| 135 |
```
|
| 136 |
|
| 137 |
*Constraints:* `T` is of the form `U[]`.
|
| 138 |
|
| 139 |
*Returns:* A `shared_ptr` to an object of type `U[N]` with a default
|
|
|
|
| 150 |
|
| 151 |
— *end example*]
|
| 152 |
|
| 153 |
``` cpp
|
| 154 |
template<class T>
|
| 155 |
+
constexpr shared_ptr<T> make_shared(); // T is U[N]
|
| 156 |
template<class T, class A>
|
| 157 |
+
constexpr shared_ptr<T> allocate_shared(const A& a); // T is U[N]
|
| 158 |
```
|
| 159 |
|
| 160 |
*Constraints:* `T` is of the form `U[N]`.
|
| 161 |
|
| 162 |
*Returns:* A `shared_ptr` to an object of type `T` with a default
|
|
|
|
| 173 |
|
| 174 |
— *end example*]
|
| 175 |
|
| 176 |
``` cpp
|
| 177 |
template<class T>
|
| 178 |
+
constexpr shared_ptr<T> make_shared(size_t N,
|
| 179 |
const remove_extent_t<T>& u); // T is U[]
|
| 180 |
template<class T, class A>
|
| 181 |
+
constexpr shared_ptr<T> allocate_shared(const A& a, size_t N,
|
| 182 |
const remove_extent_t<T>& u); // T is U[]
|
| 183 |
```
|
| 184 |
|
| 185 |
*Constraints:* `T` is of the form `U[]`.
|
| 186 |
|
|
|
|
| 200 |
|
| 201 |
— *end example*]
|
| 202 |
|
| 203 |
``` cpp
|
| 204 |
template<class T>
|
| 205 |
+
constexpr shared_ptr<T> make_shared(const remove_extent_t<T>& u); // T is U[N]
|
| 206 |
template<class T, class A>
|
| 207 |
+
constexpr shared_ptr<T> allocate_shared(const A& a,
|
| 208 |
const remove_extent_t<T>& u); // T is U[N]
|
| 209 |
```
|
| 210 |
|
| 211 |
*Constraints:* `T` is of the form `U[N]`.
|
| 212 |
|
|
|
|
| 226 |
|
| 227 |
— *end example*]
|
| 228 |
|
| 229 |
``` cpp
|
| 230 |
template<class T>
|
| 231 |
+
constexpr shared_ptr<T> make_shared_for_overwrite();
|
| 232 |
template<class T, class A>
|
| 233 |
+
constexpr shared_ptr<T> allocate_shared_for_overwrite(const A& a);
|
| 234 |
```
|
| 235 |
|
| 236 |
*Constraints:* `T` is not an array of unknown bound.
|
| 237 |
|
| 238 |
*Returns:* A `shared_ptr` to an object of type `T`.
|
|
|
|
| 250 |
|
| 251 |
— *end example*]
|
| 252 |
|
| 253 |
``` cpp
|
| 254 |
template<class T>
|
| 255 |
+
constexpr shared_ptr<T> make_shared_for_overwrite(size_t N);
|
| 256 |
template<class T, class A>
|
| 257 |
+
constexpr shared_ptr<T> allocate_shared_for_overwrite(const A& a, size_t N);
|
| 258 |
```
|
| 259 |
|
| 260 |
*Constraints:* `T` is an array of unknown bound.
|
| 261 |
|
| 262 |
*Returns:* A `shared_ptr` to an object of type `U[N]`, where `U` is
|