tmp/tmppwnphjjm/{from.md → to.md}
RENAMED
|
@@ -4,44 +4,44 @@
|
|
| 4 |
|
| 5 |
``` cpp
|
| 6 |
template <class T, class Alloc> struct uses_allocator;
|
| 7 |
```
|
| 8 |
|
| 9 |
-
|
| 10 |
-
convertible from `Alloc`. Meets the
|
| 11 |
-
requirements ([[meta.rqmts]]). The implementation
|
| 12 |
-
definition that is derived from `true_type` if
|
| 13 |
-
`T::allocator_type`
|
| 14 |
-
|
|
|
|
| 15 |
shall be derived from `false_type`. A program may specialize this
|
| 16 |
template to derive from `true_type` for a user-defined type `T` that
|
| 17 |
does not have a nested `allocator_type` but nonetheless can be
|
| 18 |
constructed with an allocator where either:
|
| 19 |
|
| 20 |
- the first argument of a constructor has type `allocator_arg_t` and the
|
| 21 |
second argument has type `Alloc` or
|
| 22 |
- the last argument of a constructor has type `Alloc`.
|
| 23 |
|
| 24 |
-
####
|
| 25 |
|
| 26 |
*Uses-allocator construction* with allocator `Alloc` refers to the
|
| 27 |
construction of an object `obj` of type `T`, using constructor arguments
|
| 28 |
`v1, v2, ..., vN` of types `V1, V2, ..., VN`, respectively, and an
|
| 29 |
allocator `alloc` of type `Alloc`, according to the following rules:
|
| 30 |
|
| 31 |
-
- if `
|
| 32 |
-
`
|
| 33 |
initialized as `obj(v1, v2, ..., vN)`;
|
| 34 |
-
- otherwise, if `
|
| 35 |
-
`
|
| 36 |
-
`
|
| 37 |
-
`obj(allocator_arg, alloc, v1,
|
| 38 |
v2, ..., vN)`;
|
| 39 |
-
- otherwise, if `
|
| 40 |
-
`
|
| 41 |
-
|
| 42 |
- otherwise, the request for uses-allocator construction is ill-formed.
|
| 43 |
-
An error will result if `
|
| 44 |
-
but the specific constructor does not take an allocator. This
|
| 45 |
definition prevents a silent failure to pass the allocator to an
|
| 46 |
-
element.
|
| 47 |
|
|
|
|
| 4 |
|
| 5 |
``` cpp
|
| 6 |
template <class T, class Alloc> struct uses_allocator;
|
| 7 |
```
|
| 8 |
|
| 9 |
+
*Remarks:* Automatically detects whether `T` has a nested
|
| 10 |
+
`allocator_type` that is convertible from `Alloc`. Meets the
|
| 11 |
+
`BinaryTypeTrait` requirements ([[meta.rqmts]]). The implementation
|
| 12 |
+
shall provide a definition that is derived from `true_type` if the
|
| 13 |
+
*qualified-id* `T::allocator_type` is valid and denotes a
|
| 14 |
+
type ([[temp.deduct]]) and
|
| 15 |
+
`is_convertible_v<Alloc, T::allocator_type> != false`, otherwise it
|
| 16 |
shall be derived from `false_type`. A program may specialize this
|
| 17 |
template to derive from `true_type` for a user-defined type `T` that
|
| 18 |
does not have a nested `allocator_type` but nonetheless can be
|
| 19 |
constructed with an allocator where either:
|
| 20 |
|
| 21 |
- the first argument of a constructor has type `allocator_arg_t` and the
|
| 22 |
second argument has type `Alloc` or
|
| 23 |
- the last argument of a constructor has type `Alloc`.
|
| 24 |
|
| 25 |
+
#### Uses-allocator construction <a id="allocator.uses.construction">[[allocator.uses.construction]]</a>
|
| 26 |
|
| 27 |
*Uses-allocator construction* with allocator `Alloc` refers to the
|
| 28 |
construction of an object `obj` of type `T`, using constructor arguments
|
| 29 |
`v1, v2, ..., vN` of types `V1, V2, ..., VN`, respectively, and an
|
| 30 |
allocator `alloc` of type `Alloc`, according to the following rules:
|
| 31 |
|
| 32 |
+
- if `uses_allocator_v<T, Alloc>` is `false` and
|
| 33 |
+
`is_constructible_v<T, V1, V2, ..., VN>` is `true`, then `obj` is
|
| 34 |
initialized as `obj(v1, v2, ..., vN)`;
|
| 35 |
+
- otherwise, if `uses_allocator_v<T, Alloc>` is `true` and
|
| 36 |
+
`is_constructible_v<T, allocator_arg_t, Alloc,` `V1, V2, ..., VN>` is
|
| 37 |
+
`true`, then `obj` is initialized as `obj(allocator_arg, alloc, v1,
|
|
|
|
| 38 |
v2, ..., vN)`;
|
| 39 |
+
- otherwise, if `uses_allocator_v<T, Alloc>` is `true` and
|
| 40 |
+
`is_constructible_v<T, V1, V2, ..., VN, Alloc>` is `true`, then `obj`
|
| 41 |
+
is initialized as `obj(v1, v2, ..., vN, alloc)`;
|
| 42 |
- otherwise, the request for uses-allocator construction is ill-formed.
|
| 43 |
+
\[*Note 1*: An error will result if `uses_allocator_v<T, Alloc>` is
|
| 44 |
+
`true` but the specific constructor does not take an allocator. This
|
| 45 |
definition prevents a silent failure to pass the allocator to an
|
| 46 |
+
element. — *end note*]
|
| 47 |
|