From Jason Turner

[allocator.uses.construction]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmpngsn_68a/{from.md → to.md} +88 -19
tmp/tmpngsn_68a/{from.md → to.md} RENAMED
@@ -35,28 +35,28 @@ return value or in-place, respectively.
35
  be specified explicitly by the caller. — *end note*]
36
 
37
  ``` cpp
38
  template<class T, class Alloc, class... Args>
39
  constexpr auto uses_allocator_construction_args(const Alloc& alloc,
40
- Args&&... args) noexcept -> see below;
41
  ```
42
 
43
- *Constraints:* `T` is not a specialization of `pair`.
44
 
45
  *Returns:* A `tuple` value determined as follows:
46
 
47
- - If `uses_allocator_v<T, Alloc>` is `false` and
48
  `is_constructible_v<T,Args...>` is `true`, return
49
  `forward_as_tuple(std::forward<Args>(args)...)`.
50
- - Otherwise, if `uses_allocator_v<T, Alloc>` is `true` and
51
  `is_constructible_v<T, allocator_arg_t, const Alloc&, Args...>` is
52
  `true`, return
53
  ``` cpp
54
  tuple<allocator_arg_t, const Alloc&, Args&&...>(
55
  allocator_arg, alloc, std::forward<Args>(args)...)
56
  ```
57
- - Otherwise, if `uses_allocator_v<T, Alloc>` is `true` and
58
  `is_constructible_v<T, Args..., const Alloc&>` is `true`, return
59
  `forward_as_tuple(std::forward<Args>(args)..., alloc)`.
60
  - Otherwise, the program is ill-formed.
61
 
62
  [*Note 1*: This definition prevents a silent failure to pass the
@@ -64,17 +64,18 @@ allocator to a constructor of a type for which
64
  `uses_allocator_v<T, Alloc>` is `true`. — *end note*]
65
 
66
  ``` cpp
67
  template<class T, class Alloc, class Tuple1, class Tuple2>
68
  constexpr auto uses_allocator_construction_args(const Alloc& alloc, piecewise_construct_t,
69
- Tuple1&& x, Tuple2&& y)
70
- noexcept -> see below;
71
  ```
72
 
73
- *Constraints:* `T` is a specialization of `pair`.
74
 
75
- *Effects:* For `T` specified as `pair<T1, T2>`, equivalent to:
 
 
76
 
77
  ``` cpp
78
  return make_tuple(
79
  piecewise_construct,
80
  apply([&alloc](auto&&... args1) {
@@ -87,14 +88,14 @@ return make_tuple(
87
  }, std::forward<Tuple2>(y)));
88
  ```
89
 
90
  ``` cpp
91
  template<class T, class Alloc>
92
- constexpr auto uses_allocator_construction_args(const Alloc& alloc) noexcept -> see below;
93
  ```
94
 
95
- *Constraints:* `T` is a specialization of `pair`.
96
 
97
  *Effects:* Equivalent to:
98
 
99
  ``` cpp
100
  return uses_allocator_construction_args<T>(alloc, piecewise_construct,
@@ -102,14 +103,14 @@ return uses_allocator_construction_args<T>(alloc, piecewise_construct,
102
  ```
103
 
104
  ``` cpp
105
  template<class T, class Alloc, class U, class V>
106
  constexpr auto uses_allocator_construction_args(const Alloc& alloc,
107
- U&& u, V&& v) noexcept -> see below;
108
  ```
109
 
110
- *Constraints:* `T` is a specialization of `pair`.
111
 
112
  *Effects:* Equivalent to:
113
 
114
  ``` cpp
115
  return uses_allocator_construction_args<T>(alloc, piecewise_construct,
@@ -118,14 +119,17 @@ return uses_allocator_construction_args<T>(alloc, piecewise_construct,
118
  ```
119
 
120
  ``` cpp
121
  template<class T, class Alloc, class U, class V>
122
  constexpr auto uses_allocator_construction_args(const Alloc& alloc,
123
- const pair<U,V>& pr) noexcept -> see below;
 
 
 
124
  ```
125
 
126
- *Constraints:* `T` is a specialization of `pair`.
127
 
128
  *Effects:* Equivalent to:
129
 
130
  ``` cpp
131
  return uses_allocator_construction_args<T>(alloc, piecewise_construct,
@@ -134,23 +138,88 @@ return uses_allocator_construction_args<T>(alloc, piecewise_construct,
134
  ```
135
 
136
  ``` cpp
137
  template<class T, class Alloc, class U, class V>
138
  constexpr auto uses_allocator_construction_args(const Alloc& alloc,
139
- pair<U,V>&& pr) noexcept -> see below;
 
 
 
140
  ```
141
 
142
- *Constraints:* `T` is a specialization of `pair`.
143
 
144
  *Effects:* Equivalent to:
145
 
146
  ``` cpp
147
  return uses_allocator_construction_args<T>(alloc, piecewise_construct,
148
- forward_as_tuple(std::move(pr).first),
149
- forward_as_tuple(std::move(pr).second));
150
  ```
151
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
152
  ``` cpp
153
  template<class T, class Alloc, class... Args>
154
  constexpr T make_obj_using_allocator(const Alloc& alloc, Args&&... args);
155
  ```
156
 
 
35
  be specified explicitly by the caller. — *end note*]
36
 
37
  ``` cpp
38
  template<class T, class Alloc, class... Args>
39
  constexpr auto uses_allocator_construction_args(const Alloc& alloc,
40
+ Args&&... args) noexcept;
41
  ```
42
 
43
+ *Constraints:* `remove_cv_t<T>` is not a specialization of `pair`.
44
 
45
  *Returns:* A `tuple` value determined as follows:
46
 
47
+ - If `uses_allocator_v<remove_cv_t<T>, Alloc>` is `false` and
48
  `is_constructible_v<T,Args...>` is `true`, return
49
  `forward_as_tuple(std::forward<Args>(args)...)`.
50
+ - Otherwise, if `uses_allocator_v<remove_cv_t<T>, Alloc>` is `true` and
51
  `is_constructible_v<T, allocator_arg_t, const Alloc&, Args...>` is
52
  `true`, return
53
  ``` cpp
54
  tuple<allocator_arg_t, const Alloc&, Args&&...>(
55
  allocator_arg, alloc, std::forward<Args>(args)...)
56
  ```
57
+ - Otherwise, if `uses_allocator_v<remove_cv_t<T>, Alloc>` is `true` and
58
  `is_constructible_v<T, Args..., const Alloc&>` is `true`, return
59
  `forward_as_tuple(std::forward<Args>(args)..., alloc)`.
60
  - Otherwise, the program is ill-formed.
61
 
62
  [*Note 1*: This definition prevents a silent failure to pass the
 
64
  `uses_allocator_v<T, Alloc>` is `true`. — *end note*]
65
 
66
  ``` cpp
67
  template<class T, class Alloc, class Tuple1, class Tuple2>
68
  constexpr auto uses_allocator_construction_args(const Alloc& alloc, piecewise_construct_t,
69
+ Tuple1&& x, Tuple2&& y) noexcept;
 
70
  ```
71
 
72
+ Let `T1` be `T::first_type`. Let `T2` be `T::second_type`.
73
 
74
+ *Constraints:* `remove_cv_t<T>` is a specialization of `pair`.
75
+
76
+ *Effects:* Equivalent to:
77
 
78
  ``` cpp
79
  return make_tuple(
80
  piecewise_construct,
81
  apply([&alloc](auto&&... args1) {
 
88
  }, std::forward<Tuple2>(y)));
89
  ```
90
 
91
  ``` cpp
92
  template<class T, class Alloc>
93
+ constexpr auto uses_allocator_construction_args(const Alloc& alloc) noexcept;
94
  ```
95
 
96
+ *Constraints:* `remove_cv_t<T>` is a specialization of `pair`.
97
 
98
  *Effects:* Equivalent to:
99
 
100
  ``` cpp
101
  return uses_allocator_construction_args<T>(alloc, piecewise_construct,
 
103
  ```
104
 
105
  ``` cpp
106
  template<class T, class Alloc, class U, class V>
107
  constexpr auto uses_allocator_construction_args(const Alloc& alloc,
108
+ U&& u, V&& v) noexcept;
109
  ```
110
 
111
+ *Constraints:* `remove_cv_t<T>` is a specialization of `pair`.
112
 
113
  *Effects:* Equivalent to:
114
 
115
  ``` cpp
116
  return uses_allocator_construction_args<T>(alloc, piecewise_construct,
 
119
  ```
120
 
121
  ``` cpp
122
  template<class T, class Alloc, class U, class V>
123
  constexpr auto uses_allocator_construction_args(const Alloc& alloc,
124
+ pair<U, V>& pr) noexcept;
125
+ template<class T, class Alloc, class U, class V>
126
+ constexpr auto uses_allocator_construction_args(const Alloc& alloc,
127
+ const pair<U, V>& pr) noexcept;
128
  ```
129
 
130
+ *Constraints:* `remove_cv_t<T>` is a specialization of `pair`.
131
 
132
  *Effects:* Equivalent to:
133
 
134
  ``` cpp
135
  return uses_allocator_construction_args<T>(alloc, piecewise_construct,
 
138
  ```
139
 
140
  ``` cpp
141
  template<class T, class Alloc, class U, class V>
142
  constexpr auto uses_allocator_construction_args(const Alloc& alloc,
143
+ pair<U, V>&& pr) noexcept;
144
+ template<class T, class Alloc, class U, class V>
145
+ constexpr auto uses_allocator_construction_args(const Alloc& alloc,
146
+ const pair<U, V>&& pr) noexcept;
147
  ```
148
 
149
+ *Constraints:* `remove_cv_t<T>` is a specialization of `pair`.
150
 
151
  *Effects:* Equivalent to:
152
 
153
  ``` cpp
154
  return uses_allocator_construction_args<T>(alloc, piecewise_construct,
155
+ forward_as_tuple(get<0>(std::move(pr))),
156
+ forward_as_tuple(get<1>(std::move(pr))));
157
  ```
158
 
159
+ ``` cpp
160
+ template<class T, class Alloc, pair-like P>
161
+ constexpr auto uses_allocator_construction_args(const Alloc& alloc, P&& p) noexcept;
162
+ ```
163
+
164
+ *Constraints:* `remove_cv_t<T>` is a specialization of `pair` and
165
+ `remove_cvref_t<P>` is not a specialization of `ranges::subrange`.
166
+
167
+ *Effects:* Equivalent to:
168
+
169
+ ``` cpp
170
+ return uses_allocator_construction_args<T>(alloc, piecewise_construct,
171
+ forward_as_tuple(get<0>(std::forward<P>(p))),
172
+ forward_as_tuple(get<1>(std::forward<P>(p))));
173
+ ```
174
+
175
+ ``` cpp
176
+ template<class T, class Alloc, class U>
177
+ constexpr auto uses_allocator_construction_args(const Alloc& alloc, U&& u) noexcept;
178
+ ```
179
+
180
+ Let *FUN* be the function template:
181
+
182
+ ``` cpp
183
+ template<class A, class B>
184
+ void FUN(const pair<A, B>&);
185
+ ```
186
+
187
+ *Constraints:* `remove_cv_t<T>` is a specialization of `pair`, and
188
+ either:
189
+
190
+ - `remove_cvref_t<U>` is a specialization of `ranges::subrange`, or
191
+ - `U` does not satisfy `pair-like` and the expression *`FUN`*`(u)` is
192
+ not well-formed when considered as an unevaluated operand.
193
+
194
+ Let *pair-constructor* be an exposition-only class defined as follows:
195
+
196
+ ``` cpp
197
+ class pair-constructor {
198
+ using pair-type = remove_cv_t<T>; // exposition only
199
+
200
+ constexpr auto do-construct(const pair-type& p) const { // exposition only
201
+ return make_obj_using_allocator<pair-type>(alloc_, p);
202
+ }
203
+ constexpr auto do-construct(pair-type&& p) const { // exposition only
204
+ return make_obj_using_allocator<pair-type>(alloc_, std::move(p));
205
+ }
206
+
207
+ const Alloc& alloc_; // exposition only
208
+ U& u_; // exposition only
209
+
210
+ public:
211
+ constexpr operator pair-type() const {
212
+ return do-construct(std::forward<U>(u_));
213
+ }
214
+ };
215
+ ```
216
+
217
+ *Returns:* `make_tuple(pc)`, where `pc` is a *pair-constructor* object
218
+ whose *alloc\_* member is initialized with `alloc` and whose *u\_*
219
+ member is initialized with `u`.
220
+
221
  ``` cpp
222
  template<class T, class Alloc, class... Args>
223
  constexpr T make_obj_using_allocator(const Alloc& alloc, Args&&... args);
224
  ```
225