Skip to content

Commit 4799fea

Browse files
Update test to use ranges API for minmax projection
The HPX non-ranges minmax CPOs do not expose a projection parameter, causing 'no matching function' compilation errors during test compilation. Using hpx::ranges::min_element routes perfectly to the correct parallel dispatches where the core algorithms are tested for correct projection SFINAE deductions.
1 parent a35a720 commit 4799fea

1 file changed

Lines changed: 10 additions & 9 deletions

File tree

libs/core/algorithms/tests/unit/algorithms/minmax_element_parallel_projection.cpp

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
// path to ensure the parallel aggregation returns an iterator (not a copy).
1212

1313
#include <hpx/algorithm.hpp>
14+
#include <hpx/parallel/container_algorithms/minmax.hpp>
1415
#include <hpx/execution.hpp>
1516
#include <hpx/init.hpp>
1617
#include <hpx/modules/testing.hpp>
@@ -26,7 +27,7 @@
2627

2728
// ---------------------------------------------------------------------------
2829
// test_min_element_parallel_projection
29-
// Verifies that hpx::min_element with par and a projection correctly
30+
// Verifies that hpx::ranges::min_element with par and a projection correctly
3031
// identifies the minimum by projected value, exercising the parallel
3132
// reduction path (sequential_minmax_element_ind returns Iter).
3233
// ---------------------------------------------------------------------------
@@ -40,7 +41,7 @@ void test_min_element_parallel_projection(ExPolicy policy)
4041
auto proj = [](std::pair<int, int> const& p) { return p.second; };
4142

4243
auto it =
43-
hpx::min_element(policy, c.begin(), c.end(), std::less<int>{}, proj);
44+
hpx::ranges::min_element(policy, c.begin(), c.end(), std::less<int>{}, proj);
4445

4546
HPX_TEST(it != c.end());
4647
// Minimum second value is 1, belonging to {20, 1}
@@ -50,7 +51,7 @@ void test_min_element_parallel_projection(ExPolicy policy)
5051

5152
// ---------------------------------------------------------------------------
5253
// test_max_element_parallel_projection
53-
// Verifies that hpx::max_element with par and a projection correctly
54+
// Verifies that hpx::ranges::max_element with par and a projection correctly
5455
// identifies the maximum by projected value, exercising the parallel
5556
// reduction path (sequential_minmax_element_ind returns Iter, not value_type).
5657
// ---------------------------------------------------------------------------
@@ -63,7 +64,7 @@ void test_max_element_parallel_projection(ExPolicy policy)
6364
auto proj = [](std::pair<int, int> const& p) { return p.second; };
6465

6566
auto it =
66-
hpx::max_element(policy, c.begin(), c.end(), std::less<int>{}, proj);
67+
hpx::ranges::max_element(policy, c.begin(), c.end(), std::less<int>{}, proj);
6768

6869
HPX_TEST(it != c.end());
6970
// Maximum second value is 8, belonging to {30, 8}
@@ -73,7 +74,7 @@ void test_max_element_parallel_projection(ExPolicy policy)
7374

7475
// ---------------------------------------------------------------------------
7576
// test_minmax_element_parallel_projection
76-
// Verifies that hpx::minmax_element with par and a projection correctly
77+
// Verifies that hpx::ranges::minmax_element with par and a projection correctly
7778
// identifies both min and max by projected value, exercising the parallel
7879
// reduction path (sequential_minmax_element_ind returns minmax_element_result<Iter>).
7980
// ---------------------------------------------------------------------------
@@ -86,7 +87,7 @@ void test_minmax_element_parallel_projection(ExPolicy policy)
8687
auto proj = [](std::pair<int, int> const& p) { return p.second; };
8788

8889
auto result =
89-
hpx::minmax_element(policy, c.begin(), c.end(), std::less<int>{}, proj);
90+
hpx::ranges::minmax_element(policy, c.begin(), c.end(), std::less<int>{}, proj);
9091

9192
HPX_TEST(result.min != c.end());
9293
HPX_TEST(result.max != c.end());
@@ -120,7 +121,7 @@ void test_min_element_parallel_projection_large(ExPolicy policy)
120121
[&proj](auto const& a, auto const& b) { return proj(a) < proj(b); });
121122

122123
auto it =
123-
hpx::min_element(policy, c.begin(), c.end(), std::less<int>{}, proj);
124+
hpx::ranges::min_element(policy, c.begin(), c.end(), std::less<int>{}, proj);
124125

125126
HPX_TEST(it != c.end());
126127
HPX_TEST_EQ(it->second, ref_it->second);
@@ -140,7 +141,7 @@ void test_max_element_parallel_projection_large(ExPolicy policy)
140141
[&proj](auto const& a, auto const& b) { return proj(a) < proj(b); });
141142

142143
auto it =
143-
hpx::max_element(policy, c.begin(), c.end(), std::less<int>{}, proj);
144+
hpx::ranges::max_element(policy, c.begin(), c.end(), std::less<int>{}, proj);
144145

145146
HPX_TEST(it != c.end());
146147
HPX_TEST_EQ(it->second, ref_it->second);
@@ -163,7 +164,7 @@ void test_minmax_element_parallel_projection_large(ExPolicy policy)
163164
[&proj](auto const& a, auto const& b) { return proj(a) < proj(b); });
164165

165166
auto result =
166-
hpx::minmax_element(policy, c.begin(), c.end(), std::less<int>{}, proj);
167+
hpx::ranges::minmax_element(policy, c.begin(), c.end(), std::less<int>{}, proj);
167168

168169
HPX_TEST(result.min != c.end());
169170
HPX_TEST(result.max != c.end());

0 commit comments

Comments
 (0)