|
7 | 7 |
|
8 | 8 | #include <boost/core/lightweight_test.hpp> |
9 | 9 |
|
| 10 | +#include <algorithm> // for sort |
10 | 11 | #include <functional> // for greater |
11 | 12 | #include <iterator> // for next |
12 | 13 |
|
13 | | -#if defined(__has_include) && !defined(__NVCC__) && !defined(__NVCOMPILER) |
14 | | -#if __has_include(<execution>) |
15 | | -#include <execution> // for std::execution::seq // IWYU pragma: keep |
16 | | -#endif |
17 | | -#endif |
18 | | - |
19 | 14 | namespace multi = boost::multi; |
20 | 15 |
|
| 16 | +namespace { |
| 17 | +// a minimal user-defined "execution policy" with an ADL-findable sort, used to exercise |
| 18 | +// the policy overload and its ADL dispatch portably (no <execution>/TBB, nvcc/nvhpc-safe). |
| 19 | +struct seq_policy {}; |
| 20 | +template<class It, class Compare> |
| 21 | +void sort(seq_policy /*policy*/, It first, It last, Compare comp) { std::sort(first, last, comp); } |
| 22 | +} // namespace |
| 23 | + |
21 | 24 | auto main() -> int { // NOLINT(readability-function-cognitive-complexity,bugprone-exception-escape) |
22 | 25 | // basic ascending order into a caller-provided output buffer |
23 | 26 | { |
@@ -114,19 +117,17 @@ auto main() -> int { // NOLINT(readability-function-cognitive-complexity,bugpro |
114 | 117 | BOOST_TEST( arr[buf[2]] == 6 ); |
115 | 118 | } |
116 | 119 |
|
117 | | -#ifdef __cpp_lib_execution |
118 | | - // execution-policy overload (also exercises disambiguation from the policy-free overloads) |
| 120 | + // policy overload + ADL sort dispatch (also exercises disambiguation from the policy-free overloads) |
119 | 121 | { |
120 | 122 | multi::array<int, 1> const arr = {3, 1, 2, 5, 4}; |
121 | 123 |
|
122 | 124 | multi::array<multi::index, 1> order(arr.extents()); |
123 | | - multi::ordering(std::execution::seq, arr, order.begin()); |
| 125 | + multi::ordering(seq_policy{}, arr, order.begin()); |
124 | 126 |
|
125 | 127 | for(multi::index k = 0; k + 1 != order.size(); ++k) { // NOLINT(altera-unroll-loops,altera-id-dependent-backward-branch) |
126 | 128 | BOOST_TEST( arr[order[k]] <= arr[order[k + 1]] ); |
127 | 129 | } |
128 | 130 | } |
129 | | -#endif |
130 | 131 |
|
131 | 132 | return boost::report_errors(); |
132 | 133 | } |
0 commit comments