Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Making set algorithms conform to C++20 #4970

Merged
merged 10 commits into from
Sep 24, 2020
24 changes: 17 additions & 7 deletions docs/sphinx/api/public_api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ Functions
- :cpp:func:`hpx::for_each_n`
- :cpp:func:`hpx::generate`
- :cpp:func:`hpx::generate_n`
- :cpp:func:`hpx::parallel::v1::includes`
- :cpp:func:`hpx::parallel::v1::inplace_merge`
- :cpp:func:`hpx::includes`
- :cpp:func:`hpx::inplace_merge`
- :cpp:func:`hpx::is_heap`
- :cpp:func:`hpx::is_heap_until`
- :cpp:func:`hpx::parallel::v1::is_partitioned`
Expand All @@ -61,7 +61,7 @@ Functions
- :cpp:func:`hpx::parallel::v1::lexicographical_compare`
- :cpp:func:`hpx::make_heap`
- :cpp:func:`hpx::parallel::v1::max_element`
- :cpp:func:`hpx::parallel::v1::merge`
- :cpp:func:`hpx::merge`
- :cpp:func:`hpx::parallel::v1::min_element`
- :cpp:func:`hpx::parallel::v1::minmax_element`
- :cpp:func:`hpx::parallel::v1::mismatch`
Expand All @@ -83,10 +83,10 @@ Functions
- :cpp:func:`hpx::parallel::v1::rotate_copy`
- :cpp:func:`hpx::parallel::v1::search`
- :cpp:func:`hpx::parallel::v1::search_n`
- :cpp:func:`hpx::parallel::v1::set_difference`
- :cpp:func:`hpx::parallel::v1::set_intersection`
- :cpp:func:`hpx::parallel::v1::set_symmetric_difference`
- :cpp:func:`hpx::parallel::v1::set_union`
- :cpp:func:`hpx::set_difference`
- :cpp:func:`hpx::set_intersection`
- :cpp:func:`hpx::set_symmetric_difference`
- :cpp:func:`hpx::set_union`
hkaiser marked this conversation as resolved.
Show resolved Hide resolved
- :cpp:func:`hpx::parallel::v1::sort`
- :cpp:func:`hpx::parallel::v1::stable_partition`
- :cpp:func:`hpx::parallel::v1::stable_sort`
Expand Down Expand Up @@ -117,8 +117,18 @@ Functions
- :cpp:func:`hpx::ranges::for_each_n`
- :cpp:func:`hpx::ranges::generate`
- :cpp:func:`hpx::ranges::generate_n`
- :cpp:func:`hpx::ranges::includes`
- :cpp:func:`hpx::ranges::inplace_merge`
- :cpp:func:`hpx::ranges::is_heap`
- :cpp:func:`hpx::ranges::is_heap_until`
- :cpp:func:`hpx::ranges::make_heap`
- :cpp:func:`hpx::ranges::merge`
- :cpp:func:`hpx::ranges::move`
- :cpp:func:`hpx::ranges::none_of`
- :cpp:func:`hpx::ranges::set_difference`
- :cpp:func:`hpx::ranges::set_intersection`
- :cpp:func:`hpx::ranges::set_symmetric_difference`
- :cpp:func:`hpx::ranges::set_union`

Header ``hpx/any.hpp``
======================
Expand Down
14 changes: 7 additions & 7 deletions docs/sphinx/manual/writing_single_node_hpx_applications.rst
Original file line number Diff line number Diff line change
Expand Up @@ -537,31 +537,31 @@ Parallel algorithms
* Description
* In header
* Algorithm page at cppreference.com
* * :cpp:func:`hpx::parallel::v1::merge`
* * :cpp:func:`hpx::merge`
* Merges two sorted ranges.
* ``<hpx/algorithm.hpp>``
* :cppreference-algorithm:`merge`
* * :cpp:func:`hpx::parallel::v1::inplace_merge`
* * :cpp:func:`hpx::inplace_merge`
* Merges two ordered ranges in-place.
* ``<hpx/algorithm.hpp>``
* :cppreference-algorithm:`inplace_merge`
* * :cpp:func:`hpx::parallel::v1::includes`
* * :cpp:func:`hpx::includes`
* Returns true if one set is a subset of another.
* ``<hpx/algorithm.hpp>``
* :cppreference-algorithm:`includes`
* * :cpp:func:`hpx::parallel::v1::set_difference`
* * :cpp:func:`hpx::set_difference`
* Computes the difference between two sets.
* ``<hpx/algorithm.hpp>``
* :cppreference-algorithm:`set_difference`
* * :cpp:func:`hpx::parallel::v1::set_intersection`
* * :cpp:func:`hpx::set_intersection`
* Computes the intersection of two sets.
* ``<hpx/algorithm.hpp>``
* :cppreference-algorithm:`set_intersection`
* * :cpp:func:`hpx::parallel::v1::set_symmetric_difference`
* * :cpp:func:`hpx::set_symmetric_difference`
* Computes the symmetric difference between two sets.
* ``<hpx/algorithm.hpp>``
* :cppreference-algorithm:`set_symmetric_difference`
* * :cpp:func:`hpx::parallel::v1::set_union`
* * :cpp:func:`hpx::set_union`
* Computes the union of two sets.
* ``<hpx/algorithm.hpp>``
* :cppreference-algorithm:`set_union`
Expand Down
7 changes: 0 additions & 7 deletions libs/full/include/include/hpx/algorithm.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,11 @@

namespace hpx {
using hpx::parallel::adjacent_find;
using hpx::parallel::includes;
using hpx::parallel::inplace_merge;
using hpx::parallel::is_partitioned;
using hpx::parallel::is_sorted;
using hpx::parallel::is_sorted_until;
using hpx::parallel::lexicographical_compare;
using hpx::parallel::max_element;
using hpx::parallel::merge;
using hpx::parallel::min_element;
using hpx::parallel::minmax_element;
using hpx::parallel::partition;
Expand All @@ -41,10 +38,6 @@ namespace hpx {
using hpx::parallel::rotate_copy;
using hpx::parallel::search;
using hpx::parallel::search_n;
using hpx::parallel::set_difference;
using hpx::parallel::set_intersection;
using hpx::parallel::set_symmetric_difference;
using hpx::parallel::set_union;
using hpx::parallel::sort;
using hpx::parallel::stable_partition;
using hpx::parallel::stable_sort;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) 2007-2015 Hartmut Kaiser
// Copyright (c) 2007-2020 Hartmut Kaiser
//
// SPDX-License-Identifier: BSL-1.0
// Distributed under the Boost Software License, Version 1.0. (See accompanying
Expand All @@ -11,3 +11,9 @@
#include <hpx/parallel/algorithms/set_intersection.hpp>
#include <hpx/parallel/algorithms/set_symmetric_difference.hpp>
#include <hpx/parallel/algorithms/set_union.hpp>

#include <hpx/parallel/container_algorithms/includes.hpp>
#include <hpx/parallel/container_algorithms/set_difference.hpp>
#include <hpx/parallel/container_algorithms/set_intersection.hpp>
#include <hpx/parallel/container_algorithms/set_symmetric_difference.hpp>
#include <hpx/parallel/container_algorithms/set_union.hpp>
7 changes: 7 additions & 0 deletions libs/parallelism/algorithms/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,12 @@ set(algorithms_headers
hpx/parallel/algorithms/detail/insertion_sort.hpp
hpx/parallel/algorithms/detail/is_sorted.hpp
hpx/parallel/algorithms/detail/parallel_stable_sort.hpp
hpx/parallel/algorithms/detail/rotate.hpp
hpx/parallel/algorithms/detail/sample_sort.hpp
hpx/parallel/algorithms/detail/set_operation.hpp
hpx/parallel/algorithms/detail/spin_sort.hpp
hpx/parallel/algorithms/detail/transfer.hpp
hpx/parallel/algorithms/detail/upper_lower_bound.hpp
hpx/parallel/algorithms/equal.hpp
hpx/parallel/algorithms/exclusive_scan.hpp
hpx/parallel/algorithms/fill.hpp
Expand Down Expand Up @@ -90,6 +92,7 @@ set(algorithms_headers
hpx/parallel/container_algorithms/for_each.hpp
hpx/parallel/container_algorithms/generate.hpp
hpx/parallel/container_algorithms.hpp
hpx/parallel/container_algorithms/includes.hpp
hpx/parallel/container_algorithms/is_heap.hpp
hpx/parallel/container_algorithms/make_heap.hpp
hpx/parallel/container_algorithms/merge.hpp
Expand All @@ -104,6 +107,10 @@ set(algorithms_headers
hpx/parallel/container_algorithms/reverse.hpp
hpx/parallel/container_algorithms/rotate.hpp
hpx/parallel/container_algorithms/search.hpp
hpx/parallel/container_algorithms/set_difference.hpp
hpx/parallel/container_algorithms/set_intersection.hpp
hpx/parallel/container_algorithms/set_symmetric_difference.hpp
hpx/parallel/container_algorithms/set_union.hpp
hpx/parallel/container_algorithms/sort.hpp
hpx/parallel/container_algorithms/stable_sort.hpp
hpx/parallel/container_algorithms/transform.hpp
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,7 @@ namespace hpx { namespace parallel { inline namespace v1 {
template <typename ExPolicy, typename FwdIter, typename F,
typename Proj = util::projection_identity,
HPX_CONCEPT_REQUIRES_(
execution::is_execution_policy<ExPolicy>::value &&
hpx::is_execution_policy<ExPolicy>::value &&
hpx::traits::is_iterator<FwdIter>::value &&
traits::is_projected<Proj, FwdIter>::value &&
traits::is_indirect_callable<ExPolicy, F,
Expand Down Expand Up @@ -456,7 +456,7 @@ namespace hpx { namespace parallel { inline namespace v1 {
template <typename ExPolicy, typename FwdIter, typename F,
typename Proj = util::projection_identity,
HPX_CONCEPT_REQUIRES_(
execution::is_execution_policy<ExPolicy>::value &&
hpx::is_execution_policy<ExPolicy>::value &&
hpx::traits::is_iterator<FwdIter>::value &&
traits::is_projected<Proj, FwdIter>::value &&
traits::is_indirect_callable<ExPolicy, F,
Expand Down Expand Up @@ -567,7 +567,7 @@ namespace hpx { namespace parallel { inline namespace v1 {
template <typename ExPolicy, typename FwdIter, typename F,
typename Proj = util::projection_identity,
HPX_CONCEPT_REQUIRES_(
execution::is_execution_policy<ExPolicy>::value&&
hpx::is_execution_policy<ExPolicy>::value&&
hpx::traits::is_iterator<FwdIter>::value&&
traits::is_projected<Proj, FwdIter>::value&&
traits::is_indirect_callable<ExPolicy, F,
Expand Down Expand Up @@ -598,7 +598,7 @@ namespace hpx {
// clang-format off
template <typename ExPolicy, typename FwdIter, typename F,
HPX_CONCEPT_REQUIRES_(
hpx::parallel::execution::is_execution_policy<ExPolicy>::value &&
hpx::is_execution_policy<ExPolicy>::value &&
hpx::traits::is_iterator<FwdIter>::value
)>
// clang-format on
Expand Down Expand Up @@ -636,7 +636,7 @@ namespace hpx {
// clang-format off
template <typename ExPolicy, typename FwdIter, typename F,
HPX_CONCEPT_REQUIRES_(
hpx::parallel::execution::is_execution_policy<ExPolicy>::value &&
hpx::is_execution_policy<ExPolicy>::value &&
hpx::traits::is_iterator<FwdIter>::value
)>
// clang-format on
Expand Down Expand Up @@ -674,7 +674,7 @@ namespace hpx {
// clang-format off
template <typename ExPolicy, typename FwdIter, typename F,
HPX_CONCEPT_REQUIRES_(
hpx::parallel::execution::is_execution_policy<ExPolicy>::value &&
hpx::is_execution_policy<ExPolicy>::value &&
hpx::traits::is_iterator<FwdIter>::value
)>
// clang-format on
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -337,27 +337,12 @@ namespace hpx { namespace parallel { inline namespace v1 {
{
};
#endif

///////////////////////////////////////////////////////////////////////
template <typename I, typename O>
O get_second_element(util::in_out_result<I, O>&& p)
{
return p.out;
}

template <typename I, typename O>
hpx::future<O> get_second_element(
hpx::future<util::in_out_result<I, O>>&& f)
{
return lcos::make_future<O>(std::move(f),
[](util::in_out_result<I, O>&& p) { return p.out; });
}
} // namespace detail

// clang-format off
template <typename ExPolicy, typename FwdIter1, typename FwdIter2,
HPX_CONCEPT_REQUIRES_(
execution::is_execution_policy<ExPolicy>::value &&
hpx::is_execution_policy<ExPolicy>::value &&
hpx::traits::is_iterator<FwdIter1>::value &&
hpx::traits::is_iterator<FwdIter2>::value)>
// clang-format on
Expand Down Expand Up @@ -427,7 +412,7 @@ namespace hpx { namespace parallel { inline namespace v1 {
template <typename ExPolicy, typename FwdIter1, typename Size,
typename FwdIter2,
HPX_CONCEPT_REQUIRES_(
execution::is_execution_policy<ExPolicy>::value &&
hpx::is_execution_policy<ExPolicy>::value &&
hpx::traits::is_iterator<FwdIter1>::value &&
hpx::traits::is_iterator<FwdIter2>::value)>
// clang-format on
Expand Down Expand Up @@ -599,7 +584,7 @@ namespace hpx { namespace parallel { inline namespace v1 {
template <typename ExPolicy, typename FwdIter1, typename FwdIter2,
typename Pred,
HPX_CONCEPT_REQUIRES_(
hpx::parallel::execution::is_execution_policy<ExPolicy>::value &&
hpx::is_execution_policy<ExPolicy>::value &&
hpx::traits::is_iterator<FwdIter1>::value &&
hpx::traits::is_iterator<FwdIter2>::value &&
hpx::traits::is_invocable<Pred,
Expand Down Expand Up @@ -638,7 +623,7 @@ namespace hpx {
// clang-format off
template <typename ExPolicy, typename FwdIter1, typename FwdIter2,
HPX_CONCEPT_REQUIRES_(
parallel::execution::is_execution_policy<ExPolicy>::value &&
hpx::is_execution_policy<ExPolicy>::value &&
hpx::traits::is_iterator<FwdIter1>::value &&
hpx::traits::is_iterator<FwdIter2>::value
)>
Expand All @@ -648,7 +633,7 @@ namespace hpx {
tag_invoke(hpx::copy_t, ExPolicy&& policy, FwdIter1 first,
FwdIter1 last, FwdIter2 dest)
{
return parallel::v1::detail::get_second_element(
return parallel::util::get_second_element(
parallel::v1::detail::transfer<
parallel::v1::detail::copy_iter<FwdIter1, FwdIter2>>(
std::forward<ExPolicy>(policy), first, last, dest));
Expand All @@ -664,7 +649,7 @@ namespace hpx {
friend FwdIter2 tag_invoke(
hpx::copy_t, FwdIter1 first, FwdIter1 last, FwdIter2 dest)
{
return parallel::v1::detail::get_second_element(
return parallel::util::get_second_element(
parallel::v1::detail::transfer<
parallel::v1::detail::copy_iter<FwdIter1, FwdIter2>>(
hpx::execution::seq, first, last, dest));
Expand All @@ -681,7 +666,7 @@ namespace hpx {
template <typename ExPolicy, typename FwdIter1, typename Size,
typename FwdIter2,
HPX_CONCEPT_REQUIRES_(
hpx::parallel::execution::is_execution_policy<ExPolicy>::value &&
hpx::is_execution_policy<ExPolicy>::value &&
hpx::traits::is_iterator<FwdIter1>::value &&
hpx::traits::is_iterator<FwdIter2>::value
)>
Expand All @@ -707,7 +692,7 @@ namespace hpx {
hpx::parallel::execution::is_sequenced_execution_policy<
ExPolicy>;

return hpx::parallel::v1::detail::get_second_element(
return hpx::parallel::util::get_second_element(
hpx::parallel::v1::detail::copy_n<
hpx::parallel::util::in_out_result<FwdIter1, FwdIter2>>()
.call(std::forward<ExPolicy>(policy), is_seq(), first,
Expand Down Expand Up @@ -737,7 +722,7 @@ namespace hpx {
FwdIter2>::get(std::move(dest));
}

return hpx::parallel::v1::detail::get_second_element(
return hpx::parallel::util::get_second_element(
hpx::parallel::v1::detail::copy_n<
hpx::parallel::util::in_out_result<FwdIter1, FwdIter2>>()
.call(hpx::execution::seq, std::true_type{}, first,
Expand All @@ -755,7 +740,7 @@ namespace hpx {
template <typename ExPolicy, typename FwdIter1, typename FwdIter2,
typename Pred,
HPX_CONCEPT_REQUIRES_(
hpx::parallel::execution::is_execution_policy<ExPolicy>::value &&
hpx::is_execution_policy<ExPolicy>::value &&
hpx::traits::is_iterator<FwdIter1>::value &&
hpx::traits::is_iterator<FwdIter2>::value &&
hpx::traits::is_invocable<Pred,
Expand All @@ -777,7 +762,7 @@ namespace hpx {
hpx::parallel::execution::is_sequenced_execution_policy<
ExPolicy>;

return hpx::parallel::v1::detail::get_second_element(
return hpx::parallel::util::get_second_element(
hpx::parallel::v1::detail::copy_if<
hpx::parallel::util::in_out_result<FwdIter1, FwdIter2>>()
.call(std::forward<ExPolicy>(policy), is_seq(), first, last,
Expand All @@ -803,7 +788,7 @@ namespace hpx {
static_assert((hpx::traits::is_forward_iterator<FwdIter2>::value),
"Requires at least forward iterator.");

return hpx::parallel::v1::detail::get_second_element(
return hpx::parallel::util::get_second_element(
hpx::parallel::v1::detail::copy_if<
hpx::parallel::util::in_out_result<FwdIter1, FwdIter2>>()
.call(hpx::execution::seq, std::true_type{}, first, last,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,7 @@ namespace hpx { namespace parallel { inline namespace v1 {
template <typename ExPolicy, typename FwdIterB, typename FwdIterE,
typename T, typename Proj = util::projection_identity,
HPX_CONCEPT_REQUIRES_(
execution::is_execution_policy<ExPolicy>::value &&
hpx::is_execution_policy<ExPolicy>::value &&
traits::is_projected<Proj, FwdIterB>::value &&
hpx::traits::is_iterator<FwdIterB>::value
)>
Expand Down Expand Up @@ -447,7 +447,7 @@ namespace hpx { namespace parallel { inline namespace v1 {
template <typename ExPolicy, typename FwdIterB, typename FwdIterE,
typename F, typename Proj = util::projection_identity,
HPX_CONCEPT_REQUIRES_(
execution::is_execution_policy<ExPolicy>::value &&
hpx::is_execution_policy<ExPolicy>::value &&
hpx::traits::is_iterator<FwdIterB>::value &&
traits::is_projected<Proj, FwdIterB>::value &&
traits::is_indirect_callable<ExPolicy, F,
Expand Down Expand Up @@ -483,7 +483,7 @@ namespace hpx {
// clang-format off
template <typename ExPolicy, typename FwdIter, typename T,
HPX_CONCEPT_REQUIRES_(
hpx::parallel::execution::is_execution_policy<ExPolicy>::value &&
hpx::is_execution_policy<ExPolicy>::value &&
hpx::traits::is_iterator<FwdIter>::value
)>
// clang-format on
Expand Down Expand Up @@ -529,7 +529,7 @@ namespace hpx {
// clang-format off
template <typename ExPolicy, typename FwdIter, typename F,
HPX_CONCEPT_REQUIRES_(
hpx::parallel::execution::is_execution_policy<ExPolicy>::value &&
hpx::is_execution_policy<ExPolicy>::value &&
hpx::traits::is_iterator<FwdIter>::value &&
hpx::traits::is_invocable<F,
typename std::iterator_traits<FwdIter>::value_type
Expand Down
Loading