@@ -437,11 +437,9 @@ namespace hpx::parallel {
437
437
FwdIter dest) noexcept (hpx::experimental::util::detail::relocation_traits<
438
438
InIter1, FwdIter>::is_noexcept_relocatable_v)
439
439
{
440
- auto count = std::distance (first, last);
441
-
442
440
return util::in_out_result<InIter1, FwdIter>{first,
443
- hpx::experimental::util::uninitialized_relocate_n_primitive (
444
- first, count , dest)};
441
+ hpx::experimental::util::uninitialized_relocate_primitive (
442
+ first, last , dest)};
445
443
}
446
444
447
445
template <typename ExPolicy, typename InIter1, typename InIter2,
@@ -469,6 +467,64 @@ namespace hpx::parallel {
469
467
};
470
468
// / \endcond
471
469
470
+ // ///////////////////////////////////////////////////////////////////////////
471
+ // uninitialized_relocate_backward
472
+ // / \cond NOINTERNAL
473
+ template <typename IterPair>
474
+ struct uninitialized_relocate_backward
475
+ : public algorithm<uninitialized_relocate_backward<IterPair>,
476
+ IterPair>
477
+ {
478
+ constexpr uninitialized_relocate_backward () noexcept
479
+ : algorithm<uninitialized_relocate_backward, IterPair>(
480
+ " uninitialized_relocate_backward" )
481
+ {
482
+ }
483
+
484
+ // non vectorized overload
485
+ template <typename ExPolicy, typename BiIter1, typename BiIter2,
486
+ // clang-format off
487
+ HPX_CONCEPT_REQUIRES_ (
488
+ hpx::is_sequenced_execution_policy_v<ExPolicy>&&
489
+ hpx::traits::is_bidirectional_iterator_v<BiIter1>&&
490
+ hpx::traits::is_bidirectional_iterator_v<BiIter2>
491
+ )>
492
+ // clang-format on
493
+ static util::in_out_result<BiIter1, BiIter2> sequential (
494
+ ExPolicy&&, BiIter1 first, BiIter1 last,
495
+ BiIter2 dest_last) noexcept (hpx::experimental::util::detail::
496
+ relocation_traits<BiIter1, BiIter2>::is_noexcept_relocatable_v)
497
+ {
498
+ return util::in_out_result<BiIter1, BiIter2>{first,
499
+ hpx::experimental::util::uninitialized_relocate_backward_primitive (
500
+ first, last, dest_last)};
501
+ }
502
+
503
+ template <typename ExPolicy, typename BiIter1, typename BiIter2,
504
+ // clang-format off
505
+ HPX_CONCEPT_REQUIRES_ (
506
+ hpx::is_execution_policy_v<ExPolicy>&&
507
+ hpx::traits::is_bidirectional_iterator_v<BiIter1>&&
508
+ hpx::traits::is_bidirectional_iterator_v<BiIter2>
509
+ )>
510
+ // clang-format on
511
+ static util::detail::algorithm_result_t <ExPolicy,
512
+ util::in_out_result<BiIter1, BiIter2>>
513
+ parallel (ExPolicy&& policy, BiIter1 first, BiIter1 last,
514
+ BiIter2 dest_last) noexcept (hpx::experimental::util::detail::
515
+ relocation_traits<BiIter1,
516
+ BiIter2>::is_noexcept_relocatable_v)
517
+ {
518
+ auto count = std::distance (first, last);
519
+
520
+ auto dest_first = std::prev (dest_last, count);
521
+
522
+ return parallel_uninitialized_relocate_n (
523
+ HPX_FORWARD (ExPolicy, policy), first, count, dest_first);
524
+ }
525
+ };
526
+ // / \endcond
527
+
472
528
} // namespace detail
473
529
} // namespace hpx::parallel
474
530
@@ -644,5 +700,87 @@ namespace hpx::experimental {
644
700
.call (HPX_FORWARD (ExPolicy, policy), first, count, dest));
645
701
}
646
702
} uninitialized_relocate{};
703
+
704
+ // /////////////////////////////////////////////////////////////////////////
705
+ // CPO for hpx::uninitialized_relocate_backward
706
+ inline constexpr struct uninitialized_relocate_backward_t final
707
+ : hpx::detail::tag_parallel_algorithm<uninitialized_relocate_backward_t >
708
+ {
709
+ // clang-format off
710
+ template <typename BiIter1, typename BiIter2,
711
+ HPX_CONCEPT_REQUIRES_ (
712
+ hpx::traits::is_iterator_v<BiIter1> &&
713
+ hpx::traits::is_iterator_v<BiIter2>
714
+ )>
715
+ // clang-format on
716
+ friend BiIter2 tag_fallback_invoke (uninitialized_relocate_backward_t ,
717
+ BiIter1 first, BiIter1 last,
718
+ BiIter2 dest_last) noexcept (util::detail::relocation_traits<BiIter1,
719
+ BiIter2>::is_noexcept_relocatable_v)
720
+ {
721
+ static_assert (hpx::traits::is_bidirectional_iterator_v<BiIter1> &&
722
+ " The 'first' and 'last' arguments must meet the requirements "
723
+ " of input iterators." );
724
+ static_assert (hpx::traits::is_bidirectional_iterator_v<BiIter2>,
725
+ " The 'dest_last' argument must meet the requirements of a "
726
+ " forward iterator." );
727
+ static_assert (util::detail::relocation_traits<BiIter1,
728
+ BiIter2>::valid_relocation,
729
+ " Relocating from this source type to this destination type is "
730
+ " ill-formed" );
731
+ // if count is representing a negative value, we do nothing
732
+ if (first == last)
733
+ {
734
+ return dest_last;
735
+ }
736
+
737
+ return parallel::util::get_second_element (
738
+ hpx::parallel::detail::uninitialized_relocate_backward<
739
+ parallel::util::in_out_result<BiIter1, BiIter2>>()
740
+ .call (hpx::execution::seq, first, last, dest_last));
741
+ }
742
+
743
+ // clang-format off
744
+ template <typename ExPolicy, typename BiIter1, typename BiIter2,
745
+ HPX_CONCEPT_REQUIRES_ (
746
+ hpx::is_execution_policy_v<ExPolicy> &&
747
+ hpx::traits::is_iterator_v<BiIter1> &&
748
+ hpx::traits::is_iterator_v<BiIter2>
749
+ )>
750
+ // clang-format on
751
+ friend typename hpx::parallel::util::detail::algorithm_result<ExPolicy,
752
+ BiIter2>::type
753
+ tag_fallback_invoke (uninitialized_relocate_backward_t ,
754
+ ExPolicy&& policy, BiIter1 first, BiIter1 last,
755
+ BiIter2 dest_last) noexcept (util::detail::relocation_traits<BiIter1,
756
+ BiIter2>::is_noexcept_relocatable_v)
757
+ {
758
+ static_assert (hpx::traits::is_input_iterator_v<BiIter1>,
759
+ " The 'first' and 'last' arguments must meet the requirements "
760
+ " of bidirectional iterators." );
761
+ static_assert (hpx::traits::is_forward_iterator_v<BiIter2>,
762
+ " The 'dest' argument must meet the requirements of a "
763
+ " bidirectional iterator." );
764
+ static_assert (util::detail::relocation_traits<BiIter1,
765
+ BiIter2>::valid_relocation,
766
+ " Relocating from this source type to this destination type is "
767
+ " ill-formed" );
768
+
769
+ auto count = std::distance (first, last);
770
+
771
+ // if count is representing a negative value, we do nothing
772
+ if (hpx::parallel::detail::is_negative (count))
773
+ {
774
+ return parallel::util::detail::algorithm_result<ExPolicy,
775
+ BiIter2>::get (HPX_MOVE (dest_last));
776
+ }
777
+
778
+ return parallel::util::get_second_element (
779
+ hpx::parallel::detail::uninitialized_relocate_backward<
780
+ parallel::util::in_out_result<BiIter1, BiIter2>>()
781
+ .call (
782
+ HPX_FORWARD (ExPolicy, policy), first, last, dest_last));
783
+ }
784
+ } uninitialized_relocate_backward{};
647
785
} // namespace hpx::experimental
648
786
#endif // DOXYGEN
0 commit comments