11
11
#include < hpx/type_support/is_trivially_relocatable.hpp>
12
12
#include < hpx/type_support/relocate_at.hpp>
13
13
14
- #include < cstring>
14
+ #include < cstring> // for memmove
15
15
#include < type_traits>
16
16
17
- #if defined(__cpp_lib_trivially_relocatable)
17
+ #include < tuple>
18
+
19
+ #if defined(HPX_HAVE_P1144_RELOCATE_AT)
18
20
#include < memory>
19
21
#endif
20
22
@@ -84,7 +86,7 @@ namespace hpx::experimental::util {
84
86
// uninitialized_relocate_n //
85
87
// ////////////////////////////
86
88
template <typename InIter, typename Size, typename FwdIter>
87
- FwdIter uninitialized_relocate_n_primitive_helper (
89
+ std::tuple<InIter, FwdIter> uninitialized_relocate_n_primitive_helper (
88
90
InIter first, Size n, FwdIter dst, buffer_memcpy_tag) noexcept
89
91
{
90
92
if (n != 0 )
@@ -106,13 +108,13 @@ namespace hpx::experimental::util {
106
108
dst += n;
107
109
}
108
110
109
- return dst;
111
+ return {first, dst} ;
110
112
}
111
113
112
114
template <typename InIter, typename Size, typename FwdIter>
113
115
// Either the buffer is not contiguous or the types are no-throw
114
116
// move constructible but not trivially relocatable
115
- FwdIter uninitialized_relocate_n_primitive_helper (
117
+ std::tuple<InIter, FwdIter> uninitialized_relocate_n_primitive_helper (
116
118
InIter first, Size n, FwdIter dst, for_loop_nothrow_tag) noexcept
117
119
{
118
120
for (Size i = 0 ; i < n; ++first, ++dst, ++i)
@@ -123,11 +125,11 @@ namespace hpx::experimental::util {
123
125
std::addressof (*first), std::addressof (*dst));
124
126
}
125
127
126
- return dst;
128
+ return {first, dst} ;
127
129
}
128
130
129
131
template <typename InIter, typename Size, typename FwdIter>
130
- FwdIter uninitialized_relocate_n_primitive_helper (
132
+ std::tuple<InIter, FwdIter> uninitialized_relocate_n_primitive_helper (
131
133
InIter first, Size n, FwdIter dst, for_loop_try_catch_tag)
132
134
{
133
135
FwdIter original_dst = dst;
@@ -158,14 +160,14 @@ namespace hpx::experimental::util {
158
160
}
159
161
}
160
162
161
- return dst;
163
+ return {first, dst} ;
162
164
}
163
165
164
166
// //////////////////////////
165
167
// uninitialized_relocate //
166
168
// //////////////////////////
167
169
template <typename InIter, typename Sent, typename FwdIter>
168
- FwdIter uninitialized_relocate_primitive_helper (
170
+ std::tuple<InIter, FwdIter> uninitialized_relocate_primitive_helper (
169
171
InIter first, Sent last, FwdIter dst, buffer_memcpy_tag) noexcept
170
172
{
171
173
return uninitialized_relocate_n_primitive_helper (
@@ -175,7 +177,7 @@ namespace hpx::experimental::util {
175
177
template <typename InIter, typename Sent, typename FwdIter>
176
178
// Either the buffer is not contiguous or the types are no-throw
177
179
// move constructible but not trivially relocatable
178
- FwdIter uninitialized_relocate_primitive_helper (
180
+ std::tuple<InIter, FwdIter> uninitialized_relocate_primitive_helper (
179
181
InIter first, Sent last, FwdIter dst, for_loop_nothrow_tag) noexcept
180
182
{
181
183
for (; first != last; ++first, ++dst)
@@ -186,11 +188,11 @@ namespace hpx::experimental::util {
186
188
std::addressof (*first), std::addressof (*dst));
187
189
}
188
190
189
- return dst;
191
+ return {first, dst} ;
190
192
}
191
193
192
194
template <typename InIter, typename Sent, typename FwdIter>
193
- FwdIter uninitialized_relocate_primitive_helper (
195
+ std::tuple<InIter, FwdIter> uninitialized_relocate_primitive_helper (
194
196
InIter first, Sent last, FwdIter dst, for_loop_try_catch_tag)
195
197
{
196
198
FwdIter original_dst = dst;
@@ -218,14 +220,15 @@ namespace hpx::experimental::util {
218
220
}
219
221
}
220
222
221
- return dst;
223
+ return {first, dst} ;
222
224
}
223
225
224
226
// ///////////////////////////////////
225
227
// uninitialized_relocate_backward //
226
228
// ///////////////////////////////////
227
229
template <typename BiIter1, typename BiIter2>
228
- BiIter2 uninitialized_relocate_backward_primitive_helper (BiIter1 first,
230
+ std::tuple<BiIter1, BiIter2>
231
+ uninitialized_relocate_backward_primitive_helper (BiIter1 first,
229
232
BiIter1 last, BiIter2 dst_last, buffer_memcpy_tag) noexcept
230
233
{
231
234
// Here we know the iterators are contiguous
@@ -242,7 +245,8 @@ namespace hpx::experimental::util {
242
245
// Either the buffer is not contiguous or the types are no-throw
243
246
// move constructible but not trivially relocatable
244
247
// dst_last is one past the last element of the destination
245
- BiIter2 uninitialized_relocate_backward_primitive_helper (BiIter1 first,
248
+ std::tuple<BiIter1, BiIter2>
249
+ uninitialized_relocate_backward_primitive_helper (BiIter1 first,
246
250
BiIter1 last, BiIter2 dst_last, for_loop_nothrow_tag) noexcept
247
251
{
248
252
while (first != last)
@@ -255,14 +259,15 @@ namespace hpx::experimental::util {
255
259
std::addressof (*last), std::addressof (*dst_last));
256
260
}
257
261
258
- return dst_last;
262
+ return {last, dst_last} ;
259
263
}
260
264
261
- template <typename InIter, typename Sent, typename FwdIter>
262
- FwdIter uninitialized_relocate_backward_primitive_helper (
263
- InIter first, Sent last, FwdIter dst_last, for_loop_try_catch_tag)
265
+ template <typename BiIter1, typename BiIter2>
266
+ std::tuple<BiIter1, BiIter2>
267
+ uninitialized_relocate_backward_primitive_helper (BiIter1 first,
268
+ BiIter1 last, BiIter2 dst_last, for_loop_try_catch_tag)
264
269
{
265
- FwdIter original_dst_last = dst_last;
270
+ BiIter2 original_dst_last = dst_last;
266
271
267
272
while (first != last)
268
273
{
@@ -289,7 +294,7 @@ namespace hpx::experimental::util {
289
294
}
290
295
}
291
296
292
- return dst_last;
297
+ return {last, dst_last} ;
293
298
}
294
299
295
300
} // namespace detail
@@ -300,7 +305,7 @@ namespace hpx::experimental::util {
300
305
template <typename InIter, typename FwdIter, typename Size,
301
306
typename iterators_are_contiguous_t >
302
307
// clang-format off
303
- FwdIter uninitialized_relocate_n_primitive (InIter first, Size n,
308
+ std::tuple<InIter, FwdIter> uninitialized_relocate_n_primitive (InIter first, Size n,
304
309
FwdIter dst, iterators_are_contiguous_t ) noexcept (
305
310
detail::relocation_traits<InIter, FwdIter>::is_noexcept_relocatable_v)
306
311
// clang-format on
@@ -317,8 +322,8 @@ namespace hpx::experimental::util {
317
322
}
318
323
319
324
template <typename InIter, typename Size, typename FwdIter>
320
- FwdIter uninitialized_relocate_n_primitive (InIter first, Size n ,
321
- FwdIter dst) noexcept (detail::relocation_traits<InIter,
325
+ std::tuple<InIter, FwdIter> uninitialized_relocate_n_primitive (InIter first,
326
+ Size n, FwdIter dst) noexcept (detail::relocation_traits<InIter,
322
327
FwdIter>::is_noexcept_relocatable_v)
323
328
{
324
329
using iterators_are_contiguous_default_t =
@@ -335,7 +340,7 @@ namespace hpx::experimental::util {
335
340
template <typename InIter, typename Sent, typename FwdIter,
336
341
typename iterators_are_contiguous_t >
337
342
// clang-format off
338
- FwdIter uninitialized_relocate_primitive (InIter first, Sent last,
343
+ std::tuple<InIter, FwdIter> uninitialized_relocate_primitive (InIter first, Sent last,
339
344
FwdIter dst, iterators_are_contiguous_t ) noexcept (
340
345
detail::relocation_traits<InIter, FwdIter>::is_noexcept_relocatable_v)
341
346
// clang-format on
@@ -353,8 +358,8 @@ namespace hpx::experimental::util {
353
358
}
354
359
355
360
template <typename InIter, typename Sent, typename FwdIter>
356
- FwdIter uninitialized_relocate_primitive (InIter first, Sent last ,
357
- FwdIter dst) noexcept (detail::relocation_traits<InIter,
361
+ std::tuple<InIter, FwdIter> uninitialized_relocate_primitive (InIter first,
362
+ Sent last, FwdIter dst) noexcept (detail::relocation_traits<InIter,
358
363
FwdIter>::is_noexcept_relocatable_v)
359
364
{
360
365
using iterators_are_contiguous_default_t =
@@ -371,7 +376,7 @@ namespace hpx::experimental::util {
371
376
template <typename BiIter1, typename BiIter2,
372
377
typename iterators_are_contiguous_t >
373
378
// clang-format off
374
- BiIter2 uninitialized_relocate_backward_primitive (BiIter1 first, BiIter1 last,
379
+ std::tuple<BiIter1, BiIter2> uninitialized_relocate_backward_primitive (BiIter1 first, BiIter1 last,
375
380
BiIter2 dst_last, iterators_are_contiguous_t ) noexcept (
376
381
detail::relocation_traits<BiIter1, BiIter2>::is_noexcept_relocatable_v)
377
382
// clang-format on
@@ -389,8 +394,8 @@ namespace hpx::experimental::util {
389
394
}
390
395
391
396
template <typename BiIter1, typename BiIter2>
392
- BiIter2 uninitialized_relocate_backward_primitive (BiIter1 first,
393
- BiIter1 last,
397
+ std::tuple<BiIter1, BiIter2> uninitialized_relocate_backward_primitive (
398
+ BiIter1 first, BiIter1 last,
394
399
BiIter2 dst_last) noexcept (detail::relocation_traits<BiIter1,
395
400
BiIter2>::is_noexcept_relocatable_v)
396
401
{
0 commit comments