• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

STEllAR-GROUP / hpx / #863

11 Jan 2023 05:02PM UTC coverage: 86.533% (-0.05%) from 86.582%
#863

push

StellarBot
Merge #6126

6126: Deprecate hpx::parallel::task_block in favor of hpx::experimental::ta… r=hkaiser a=dimitraka



Co-authored-by: kadimitra <kadimitra@ece.auth.gr>

174614 of 201789 relevant lines covered (86.53%)

1954694.49 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

97.67
/libs/core/algorithms/include/hpx/parallel/algorithms/uninitialized_move.hpp
1
//  Copyright (c) 2014-2022 Hartmut Kaiser
2
//
3
//  SPDX-License-Identifier: BSL-1.0
4
//  Distributed under the Boost Software License, Version 1.0. (See accompanying
5
//  file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
6

7
/// \file parallel/algorithms/uninitialized_move.hpp
8

9
#pragma once
10

11
#if defined(DOXYGEN)
12
namespace hpx {
13
    /// Moves the elements in the range, defined by [first, last), to an
14
    /// uninitialized memory area beginning at \a dest. If an exception is
15
    /// thrown during the initialization, some objects in [first, last) are
16
    /// left in a valid but unspecified state.
17
    ///
18
    /// \note   Complexity: Performs exactly \a last - \a first assignments.
19
    ///
20
    /// \tparam InIter      The type of the source iterators used (deduced).
21
    ///                     This iterator type must meet the requirements of an
22
    ///                     input iterator.
23
    /// \tparam FwdIter     The type of the iterator representing the
24
    ///                     destination range (deduced).
25
    ///                     This iterator type must meet the requirements of a
26
    ///                     forward iterator.
27
    ///
28
    /// \param first        Refers to the beginning of the sequence of elements
29
    ///                     the algorithm will be applied to.
30
    /// \param last         Refers to the end of the sequence of elements the
31
    ///                     algorithm will be applied to.
32
    /// \param dest         Refers to the beginning of the destination range.
33
    ///
34
    /// \returns  The \a uninitialized_move algorithm returns \a FwdIter.
35
    ///           The \a uninitialized_move algorithm returns the output
36
    ///           iterator to the element in the destination range, one past
37
    ///           the last element moved.
38
    ///
39
    template <typename InIter, typename FwdIter>
40
    FwdIter uninitialized_move(InIter first, InIter last, FwdIter dest);
41

42
    /// Moves the elements in the range, defined by [first, last), to an
43
    /// uninitialized memory area beginning at \a dest. If an exception is
44
    /// thrown during the initialization, some objects in [first, last) are
45
    /// left in a valid but unspecified state. Executed according to the
46
    /// policy.
47
    ///
48
    /// \note   Complexity: Performs exactly \a last - \a first assignments.
49
    ///
50
    /// \tparam ExPolicy    The type of the execution policy to use (deduced).
51
    ///                     It describes the manner in which the execution
52
    ///                     of the algorithm may be parallelized and the manner
53
    ///                     in which it executes the assignments.
54
    /// \tparam FwdIter1    The type of the source iterators used (deduced).
55
    ///                     This iterator type must meet the requirements of a
56
    ///                     forward iterator.
57
    /// \tparam FwdIter2    The type of the iterator representing the
58
    ///                     destination range (deduced).
59
    ///                     This iterator type must meet the requirements of a
60
    ///                     forward iterator.
61
    ///
62
    /// \param policy       The execution policy to use for the scheduling of
63
    ///                     the iterations.
64
    /// \param first        Refers to the beginning of the sequence of elements
65
    ///                     the algorithm will be applied to.
66
    /// \param last         Refers to the end of the sequence of elements the
67
    ///                     algorithm will be applied to.
68
    /// \param dest         Refers to the beginning of the destination range.
69
    ///
70
    /// The assignments in the parallel \a uninitialized_move algorithm invoked
71
    /// with an execution policy object of type \a sequenced_policy
72
    /// execute in sequential order in the calling thread.
73
    ///
74
    /// The assignments in the parallel \a uninitialized_move algorithm invoked
75
    /// with an execution policy object of type \a parallel_policy or
76
    /// \a parallel_task_policy are permitted to execute in an
77
    /// unordered fashion in unspecified threads, and indeterminately sequenced
78
    /// within each thread.
79
    ///
80
    /// \returns  The \a uninitialized_move algorithm returns a
81
    ///           \a hpx::future<FwdIter2>, if the execution policy is of type
82
    ///           \a sequenced_task_policy or
83
    ///           \a parallel_task_policy and
84
    ///           returns \a FwdIter2 otherwise.
85
    ///           The \a uninitialized_move algorithm returns the output
86
    ///           iterator to the element in the destination range, one past
87
    ///           the last element moved.
88
    ///
89
    template <typename ExPolicy, typename FwdIter1, typename FwdIter2>
90
    typename parallel::util::detail::algorithm_result<ExPolicy, FwdIter2>::type
91
    uninitialized_move(
92
        ExPolicy&& policy, FwdIter1 first, FwdIter1 last, FwdIter2 dest);
93

94
    /// Moves the elements in the range [first, first + count), starting from
95
    /// first and proceeding to first + count - 1., to another range beginning
96
    /// at dest. If an exception is
97
    /// thrown during the initialization, some objects in [first, first + count)
98
    /// are left in a valid but unspecified state.
99
    ///
100
    /// \note   Complexity: Performs exactly \a count movements, if
101
    ///         count > 0, no move operations otherwise.
102
    ///
103
    /// \tparam InIter      The type of the source iterators used (deduced).
104
    ///                     This iterator type must meet the requirements of an
105
    ///                     input iterator.
106
    /// \tparam Size        The type of the argument specifying the number of
107
    ///                     elements to apply \a f to.
108
    /// \tparam FwdIter     The type of the iterator representing the
109
    ///                     destination range (deduced).
110
    ///                     This iterator type must meet the requirements of a
111
    ///                     forward iterator.
112
    ///
113
    /// \param first        Refers to the beginning of the sequence of elements
114
    ///                     the algorithm will be applied to.
115
    /// \param count        Refers to the number of elements starting at
116
    ///                     \a first the algorithm will be applied to.
117
    /// \param dest         Refers to the beginning of the destination range.
118
    ///
119
    /// \returns  The \a uninitialized_move_n algorithm returns a
120
    ///           returns \a std::pair<InIter,FwdIter>.
121
    ///           The \a uninitialized_move_n algorithm returns A pair whose
122
    ///           first element is an iterator to the element past the last
123
    ///           element moved in the source range, and whose second element
124
    ///           is an iterator to the element past the last element moved
125
    ///           in the destination range.
126
    ///
127
    template <typename InIter, typename Size, typename FwdIter>
128
    std::pair<InIter, FwdIter> uninitialized_move_n(
129
        InIter first, Size count, FwdIter dest);
130

131
    /// Moves the elements in the range [first, first + count), starting from
132
    /// first and proceeding to first + count - 1., to another range beginning
133
    /// at dest. If an exception is
134
    /// thrown during the initialization, some objects in [first, first + count)
135
    /// are left in a valid but unspecified state. Executed according to the
136
    /// policy.
137
    ///
138
    /// \note   Complexity: Performs exactly \a count movements, if
139
    ///         count > 0, no move operations otherwise.
140
    ///
141
    /// \tparam ExPolicy    The type of the execution policy to use (deduced).
142
    ///                     It describes the manner in which the execution
143
    ///                     of the algorithm may be parallelized and the manner
144
    ///                     in which it executes the assignments.
145
    /// \tparam FwdIter1    The type of the source iterators used (deduced).
146
    ///                     This iterator type must meet the requirements of a
147
    ///                     forward iterator.
148
    /// \tparam Size        The type of the argument specifying the number of
149
    ///                     elements to apply \a f to.
150
    /// \tparam FwdIter2    The type of the iterator representing the
151
    ///                     destination range (deduced).
152
    ///                     This iterator type must meet the requirements of a
153
    ///                     forward iterator.
154
    ///
155
    /// \param policy       The execution policy to use for the scheduling of
156
    ///                     the iterations.
157
    /// \param first        Refers to the beginning of the sequence of elements
158
    ///                     the algorithm will be applied to.
159
    /// \param count        Refers to the number of elements starting at
160
    ///                     \a first the algorithm will be applied to.
161
    /// \param dest         Refers to the beginning of the destination range.
162
    ///
163
    /// The assignments in the parallel \a uninitialized_move_n algorithm
164
    /// invoked with an execution policy object of type
165
    /// \a sequenced_policy execute in sequential order in the
166
    /// calling thread.
167
    ///
168
    /// The assignments in the parallel \a uninitialized_move_n algorithm
169
    /// invoked with an execution policy object of type
170
    /// \a parallel_policy or
171
    /// \a parallel_task_policy are permitted to execute in an
172
    /// unordered fashion in unspecified threads, and indeterminately sequenced
173
    /// within each thread.
174
    ///
175
    /// \returns  The \a uninitialized_move_n algorithm returns a
176
    ///           \a hpx::future<std::pair<FwdIter1,FwdIter2>>
177
    ///           if the execution policy is of type
178
    ///           \a sequenced_task_policy or
179
    ///           \a parallel_task_policy and
180
    ///           returns \a std::pair<FwdIter1,FwdIter2> otherwise.
181
    ///           The \a uninitialized_move_n algorithm returns A pair whose
182
    ///           first element is an iterator to the element past the last
183
    ///           element moved in the source range, and whose second element
184
    ///           is an iterator to the element past the last element moved
185
    ///           in the destination range.
186
    ///
187
    template <typename ExPolicy, typename FwdIter1, typename Size,
188
        typename FwdIter2>
189
    typename parallel::util::detail::algorithm_result<ExPolicy,
190
        std::pair<FwdIter1, FwdIter2>>::type
191
    uninitialized_move_n(
192
        ExPolicy&& policy, FwdIter1 first, Size count, FwdIter2 dest);
193
}    // namespace hpx
194

195
#else    // DOXYGEN
196

197
#include <hpx/config.hpp>
198
#include <hpx/concepts/concepts.hpp>
199
#include <hpx/functional/detail/tag_fallback_invoke.hpp>
200
#include <hpx/iterator_support/traits/is_iterator.hpp>
201
#include <hpx/type_support/construct_at.hpp>
202

203
#include <hpx/execution/algorithms/detail/is_negative.hpp>
204
#include <hpx/executors/execution_policy.hpp>
205
#include <hpx/parallel/algorithms/detail/dispatch.hpp>
206
#include <hpx/parallel/algorithms/detail/distance.hpp>
207
#include <hpx/parallel/util/cancellation_token.hpp>
208
#include <hpx/parallel/util/detail/algorithm_result.hpp>
209
#include <hpx/parallel/util/detail/clear_container.hpp>
210
#include <hpx/parallel/util/detail/sender_util.hpp>
211
#include <hpx/parallel/util/loop.hpp>
212
#include <hpx/parallel/util/partitioner_with_cleanup.hpp>
213
#include <hpx/parallel/util/result_types.hpp>
214
#include <hpx/parallel/util/zip_iterator.hpp>
215

216
#include <algorithm>
217
#include <cstddef>
218
#include <iterator>
219
#include <memory>
220
#include <type_traits>
221
#include <utility>
222
#include <vector>
223

224
namespace hpx { namespace parallel { inline namespace v1 {
225
    ///////////////////////////////////////////////////////////////////////////
226
    // uninitialized_move
227
    namespace detail {
228
        /// \cond NOINTERNAL
229

230
        ///////////////////////////////////////////////////////////////////////
231
        template <typename InIter1, typename FwdIter2, typename Cond>
232
        util::in_out_result<InIter1, FwdIter2> sequential_uninitialized_move(
34✔
233
            InIter1 first, FwdIter2 dest, Cond cond)
234
        {
235
            FwdIter2 current = dest;
34✔
236
            try
237
            {
238
                for (/* */; HPX_INVOKE(cond, first, current);
195,986✔
239
                     (void) ++first, ++current)
195,952✔
240
                {
241
                    hpx::construct_at(
195,952✔
242
                        std::addressof(*current), HPX_MOVE(*first));
195,968✔
243
                }
195,952✔
244
                return util::in_out_result<InIter1, FwdIter2>{first, current};
18✔
245
            }
16✔
246
            catch (...)
247
            {
248
                for (/* */; dest != current; ++dest)
43,718✔
249
                {
250
                    std::destroy_at(std::addressof(*dest));
43,702✔
251
                }
43,702✔
252
                throw;
16✔
253
            }
16✔
254
        }
32✔
255

256
        ///////////////////////////////////////////////////////////////////////
257
        template <typename InIter1, typename InIter2>
258
        util::in_out_result<InIter1, InIter2> sequential_uninitialized_move_n(
571✔
259
            InIter1 first, std::size_t count, InIter2 dest,
260
            util::cancellation_token<util::detail::no_data>& tok)
261
        {
262
            return util::in_out_result<InIter1, InIter2>{
1,473✔
263
                std::next(first, count),
571✔
264
                util::loop_with_cleanup_n_with_token(
571✔
265
                    first, count, dest, tok,
571✔
266
                    [](InIter1 it, InIter2 dest) -> void {
348,524✔
267
                        hpx::construct_at(std::addressof(*dest), HPX_MOVE(*it));
348,564✔
268
                    },
348,564✔
269
                    [](InIter2 dest) -> void {
8,216✔
270
                        std::destroy_at(std::addressof(*dest));
8,216✔
271
                    })};
8,216✔
272
        }
96✔
273

274
        ///////////////////////////////////////////////////////////////////////
275
        template <typename ExPolicy, typename Iter, typename FwdIter2>
276
        typename util::detail::algorithm_result<ExPolicy,
277
            util::in_out_result<Iter, FwdIter2>>::type
278
        parallel_sequential_uninitialized_move_n(
54✔
279
            ExPolicy&& policy, Iter first, std::size_t count, FwdIter2 dest)
280
        {
281
            if (count == 0)
54✔
282
            {
283
                return util::detail::algorithm_result<ExPolicy,
12✔
284
                    util::in_out_result<Iter, FwdIter2>>::
285
                    get(util::in_out_result<Iter, FwdIter2>{first, dest});
×
286
            }
287

288
            typedef hpx::util::zip_iterator<Iter, FwdIter2> zip_iterator;
289
            typedef std::pair<FwdIter2, FwdIter2> partition_result_type;
290
            typedef
291
                typename std::iterator_traits<FwdIter2>::value_type value_type;
292

293
            util::cancellation_token<util::detail::no_data> tok;
54✔
294
            return util::partitioner_with_cleanup<ExPolicy,
54✔
295
                util::in_out_result<Iter, FwdIter2>, partition_result_type>::
296
                call(
297
                    HPX_FORWARD(ExPolicy, policy), zip_iterator(first, dest),
54✔
298
                    count,
54✔
299
                    [tok](zip_iterator t, std::size_t part_size) mutable
3,071✔
300
                    -> partition_result_type {
301
                        using hpx::get;
302
                        auto iters = t.get_iterator_tuple();
571✔
303
                        FwdIter2 dest = get<1>(iters);
571✔
304
                        return std::make_pair(dest,
571✔
305
                            util::get_second_element(
475✔
306
                                sequential_uninitialized_move_n(
571✔
307
                                    get<0>(iters), part_size, dest, tok)));
571✔
308
                    },
336✔
309
                    // finalize, called once if no error occurred
310
                    [first, dest, count](auto&& data) mutable
228✔
311
                    -> util::in_out_result<Iter, FwdIter2> {
312
                        // make sure iterators embedded in function object that is
313
                        // attached to futures are invalidated
314
                        util::detail::clear_container(data);
30✔
315

316
                        std::advance(first, count);
30✔
317
                        std::advance(dest, count);
30✔
318
                        return util::in_out_result<Iter, FwdIter2>{first, dest};
30✔
319
                    },
320
                    // cleanup function, called for each partition which
321
                    // didn't fail, but only if at least one failed
322
                    [](partition_result_type&& r) -> void {
144✔
323
                        while (r.first != r.second)
143,872✔
324
                        {
325
                            (*r.first).~value_type();
143,728✔
326
                            ++r.first;
143,728✔
327
                        }
328
                    });
144✔
329
        }
54✔
330

331
        ///////////////////////////////////////////////////////////////////////
332
        template <typename IterPair>
333
        struct uninitialized_move
334
          : public detail::algorithm<uninitialized_move<IterPair>, IterPair>
335
        {
336
            uninitialized_move()
28✔
337
              : uninitialized_move::algorithm("uninitialized_move")
28✔
338
            {
28✔
339
            }
28✔
340

341
            template <typename ExPolicy, typename InIter1, typename Sent,
342
                typename FwdIter2>
343
            static util::in_out_result<InIter1, FwdIter2> sequential(
14✔
344
                ExPolicy, InIter1 first, Sent last, FwdIter2 dest)
345
            {
346
                return sequential_uninitialized_move(
14✔
347
                    first, dest, [last](InIter1 first, FwdIter2) -> bool {
103,780✔
348
                        return first != last;
103,758✔
349
                    });
350
            }
8✔
351

352
            template <typename ExPolicy, typename Iter, typename Sent,
353
                typename FwdIter2>
354
            static typename util::detail::algorithm_result<ExPolicy,
355
                util::in_out_result<Iter, FwdIter2>>::type
356
            parallel(ExPolicy&& policy, Iter first, Sent last, FwdIter2 dest)
14✔
357
            {
358
                return parallel_sequential_uninitialized_move_n(
14✔
359
                    HPX_FORWARD(ExPolicy, policy), first,
14✔
360
                    detail::distance(first, last), dest);
14✔
361
            }
4✔
362
        };
363
        /// \endcond
364
    }    // namespace detail
365

366
    /////////////////////////////////////////////////////////////////////////////
367
    // uninitialized_move_sent
368
    namespace detail {
369
        /// \cond NOINTERNAL
370
        template <typename IterPair>
371
        struct uninitialized_move_sent
372
          : public detail::algorithm<uninitialized_move_sent<IterPair>,
373
                IterPair>
374
        {
375
            uninitialized_move_sent()
40✔
376
              : uninitialized_move_sent::algorithm("uninitialized_move_sent")
40✔
377
            {
40✔
378
            }
40✔
379

380
            template <typename ExPolicy, typename InIter1, typename Sent1,
381
                typename FwdIter2, typename Sent2>
382
            static util::in_out_result<InIter1, FwdIter2> sequential(ExPolicy,
20✔
383
                InIter1 first, Sent1 last, FwdIter2 dest, Sent2 last_d)
384
            {
385
                return sequential_uninitialized_move(first, dest,
32✔
386
                    [last, last_d](InIter1 first, FwdIter2 current) -> bool {
92,256✔
387
                        return !(first == last || current == last_d);
92,228✔
388
                    });
389
            }
8✔
390

391
            template <typename ExPolicy, typename Iter, typename Sent1,
392
                typename FwdIter2, typename Sent2>
393
            static typename util::detail::algorithm_result<ExPolicy,
394
                util::in_out_result<Iter, FwdIter2>>::type
395
            parallel(ExPolicy&& policy, Iter first, Sent1 last, FwdIter2 dest,
20✔
396
                Sent2 last_d)
397
            {
398
                std::size_t dist1 = detail::distance(first, last);
24✔
399
                std::size_t dist2 = detail::distance(dest, last_d);
20✔
400
                std::size_t dist = dist1 <= dist2 ? dist1 : dist2;
20✔
401

402
                return parallel_sequential_uninitialized_move_n(
20✔
403
                    HPX_FORWARD(ExPolicy, policy), first, dist, dest);
20✔
404
            }
4✔
405
        };
406
        /// \endcond
407
    }    // namespace detail
408

409
    /////////////////////////////////////////////////////////////////////////////
410
    // uninitialized_move_n
411
    namespace detail {
412
        /// \cond NOINTERNAL
413

414
        // provide our own implementation of std::uninitialized_move_n as some
415
        // versions of MSVC horribly fail at compiling it for some types T
416
        template <typename InIter1, typename InIter2>
417
        util::in_out_result<InIter1, InIter2> std_uninitialized_move_n(
20✔
418
            InIter1 first, std::size_t count, InIter2 d_first)
419
        {
420
            InIter2 current = d_first;
20✔
421
            try
422
            {
423
                for (/* */; count != 0; ++first, (void) ++current, --count)
126,457✔
424
                {
425
                    hpx::construct_at(
126,437✔
426
                        std::addressof(*current), HPX_MOVE(*first));
126,445✔
427
                }
126,437✔
428
                return util::in_out_result<InIter1, InIter2>{first, current};
12✔
429
            }
8✔
430
            catch (...)
431
            {
432
                for (/* */; d_first != current; ++d_first)
36,721✔
433
                {
434
                    std::destroy_at(std::addressof(*d_first));
36,713✔
435
                }
36,713✔
436
                throw;
8✔
437
            }
8✔
438
        }
16✔
439

440
        template <typename IterPair>
441
        struct uninitialized_move_n
442
          : public detail::algorithm<uninitialized_move_n<IterPair>, IterPair>
443
        {
444
            uninitialized_move_n()
40✔
445
              : uninitialized_move_n::algorithm("uninitialized_move_n")
40✔
446
            {
40✔
447
            }
40✔
448

449
            template <typename ExPolicy, typename InIter1, typename InIter2>
450
            static IterPair sequential(
20✔
451
                ExPolicy, InIter1 first, std::size_t count, InIter2 dest)
452
            {
453
                return std_uninitialized_move_n(first, count, dest);
20✔
454
            }
8✔
455

456
            template <typename ExPolicy, typename Iter, typename FwdIter2>
457
            static typename util::detail::algorithm_result<ExPolicy,
458
                IterPair>::type
459
            parallel(
20✔
460
                ExPolicy&& policy, Iter first, std::size_t count, FwdIter2 dest)
461
            {
462
                return parallel_sequential_uninitialized_move_n(
20✔
463
                    HPX_FORWARD(ExPolicy, policy), first, count, dest);
20✔
464
            }
4✔
465
        };
466
        /// \endcond
467
    }    // namespace detail
468
}}}      // namespace hpx::parallel::v1
469

470
namespace hpx {
471
    ///////////////////////////////////////////////////////////////////////////
472
    // CPO for hpx::uninitialized_move
473
    inline constexpr struct uninitialized_move_t final
474
      : hpx::detail::tag_parallel_algorithm<uninitialized_move_t>
475
    {
476
        // clang-format off
477
        template <typename InIter, typename FwdIter,
478
            HPX_CONCEPT_REQUIRES_(
479
                hpx::traits::is_iterator<InIter>::value &&
480
                hpx::traits::is_forward_iterator<FwdIter>::value
481
            )>
482
        // clang-format on
483
        friend FwdIter tag_fallback_invoke(
2✔
484
            hpx::uninitialized_move_t, InIter first, InIter last, FwdIter dest)
485
        {
486
            static_assert(hpx::traits::is_input_iterator<InIter>::value,
487
                "Required at least input iterator.");
488
            static_assert(hpx::traits::is_forward_iterator<FwdIter>::value,
489
                "Requires at least forward iterator.");
490

491
            return parallel::util::get_second_element(
2✔
492
                hpx::parallel::v1::detail::uninitialized_move<
2✔
493
                    parallel::util::in_out_result<InIter, FwdIter>>()
494
                    .call(hpx::execution::seq, first, last, dest));
2✔
495
        }
496

497
        // clang-format off
498
        template <typename ExPolicy, typename FwdIter1, typename FwdIter2,
499
            HPX_CONCEPT_REQUIRES_(
500
                hpx::is_execution_policy<ExPolicy>::value &&
501
                hpx::traits::is_forward_iterator<FwdIter1>::value &&
502
                hpx::traits::is_forward_iterator<FwdIter2>::value
503
            )>
504
        // clang-format on
505
        friend typename parallel::util::detail::algorithm_result<ExPolicy,
506
            FwdIter2>::type
507
        tag_fallback_invoke(hpx::uninitialized_move_t, ExPolicy&& policy,
26✔
508
            FwdIter1 first, FwdIter1 last, FwdIter2 dest)
509
        {
510
            static_assert(hpx::traits::is_forward_iterator<FwdIter1>::value,
511
                "Requires at least forward iterator.");
512
            static_assert(hpx::traits::is_forward_iterator<FwdIter2>::value,
513
                "Requires at least forward iterator.");
514

515
            return parallel::util::get_second_element(
26✔
516
                hpx::parallel::v1::detail::uninitialized_move<
18✔
517
                    parallel::util::in_out_result<FwdIter1, FwdIter2>>()
518
                    .call(HPX_FORWARD(ExPolicy, policy), first, last, dest));
18✔
519
        }
×
520

521
    } uninitialized_move{};
522

523
    ///////////////////////////////////////////////////////////////////////////
524
    // CPO for hpx::uninitialized_move_n
525
    inline constexpr struct uninitialized_move_n_t final
526
      : hpx::detail::tag_parallel_algorithm<uninitialized_move_n_t>
527
    {
528
        // clang-format off
529
        template <typename InIter, typename Size,
530
            typename FwdIter,
531
            HPX_CONCEPT_REQUIRES_(
532
                hpx::traits::is_iterator<InIter>::value &&
533
                hpx::traits::is_forward_iterator<FwdIter>::value
534
            )>
535
        // clang-format on
536
        friend std::pair<InIter, FwdIter> tag_fallback_invoke(
2✔
537
            hpx::uninitialized_move_n_t, InIter first, Size count, FwdIter dest)
538
        {
539
            static_assert(hpx::traits::is_input_iterator<InIter>::value,
540
                "Required at least input iterator.");
541
            static_assert(hpx::traits::is_forward_iterator<FwdIter>::value,
542
                "Requires at least forward iterator.");
543

544
            // if count is representing a negative value, we do nothing
545
            if (hpx::parallel::v1::detail::is_negative(count))
546
            {
547
                return std::pair<InIter, FwdIter>(first, dest);
548
            }
549

550
            return parallel::util::get_pair(
2✔
551
                hpx::parallel::v1::detail::uninitialized_move_n<
2✔
552
                    parallel::util::in_out_result<InIter, FwdIter>>()
553
                    .call(
2✔
554
                        hpx::execution::seq, first, std::size_t(count), dest));
2✔
555
        }
556

557
        // clang-format off
558
        template <typename ExPolicy, typename FwdIter1, typename Size, typename FwdIter2,
559
            HPX_CONCEPT_REQUIRES_(
560
                hpx::is_execution_policy<ExPolicy>::value &&
561
                hpx::traits::is_forward_iterator<FwdIter1>::value &&
562
                hpx::traits::is_forward_iterator<FwdIter2>::value
563
            )>
564
        // clang-format on
565
        friend typename parallel::util::detail::algorithm_result<ExPolicy,
566
            std::pair<FwdIter1, FwdIter2>>::type
567
        tag_fallback_invoke(hpx::uninitialized_move_n_t, ExPolicy&& policy,
26✔
568
            FwdIter1 first, Size count, FwdIter2 dest)
569
        {
570
            static_assert(hpx::traits::is_forward_iterator<FwdIter1>::value,
571
                "Requires at least forward iterator.");
572
            static_assert(hpx::traits::is_forward_iterator<FwdIter2>::value,
573
                "Requires at least forward iterator.");
574

575
            // if count is representing a negative value, we do nothing
576
            if (hpx::parallel::v1::detail::is_negative(count))
577
            {
578
                return parallel::util::detail::algorithm_result<ExPolicy,
579
                    std::pair<FwdIter1, FwdIter2>>::get(std::pair<FwdIter1,
580
                    FwdIter2>(first, dest));
581
            }
582

583
            return parallel::util::get_pair(
26✔
584
                hpx::parallel::v1::detail::uninitialized_move_n<
18✔
585
                    parallel::util::in_out_result<FwdIter1, FwdIter2>>()
586
                    .call(HPX_FORWARD(ExPolicy, policy), first,
52✔
587
                        std::size_t(count), dest));
18✔
588
        }
×
589

590
    } uninitialized_move_n{};
591
}    // namespace hpx
592

593
#endif    // DOXYGEN
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc