Skip to content

Commit f36c551

Browse files
alfCclaude
authored andcommitted
test: exercise policy overload via a portable user policy, not std::execution
std::execution::seq broke nvcc/nvhpc (header guarded out yet __cpp_lib_execution still defined) and IWYU (demanded internal <pstl/...> headers). Replace with a tiny user-defined policy whose ADL-found sort exercises the policy overload and the ADL-preferred dispatch path directly, with no <execution>/TBB dependency. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
1 parent cdd14c6 commit f36c551

1 file changed

Lines changed: 11 additions & 10 deletions

File tree

test/ordering.cpp

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,20 @@
77

88
#include <boost/core/lightweight_test.hpp>
99

10+
#include <algorithm> // for sort
1011
#include <functional> // for greater
1112
#include <iterator> // for next
1213

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-
1914
namespace multi = boost::multi;
2015

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+
2124
auto main() -> int { // NOLINT(readability-function-cognitive-complexity,bugprone-exception-escape)
2225
// basic ascending order into a caller-provided output buffer
2326
{
@@ -114,19 +117,17 @@ auto main() -> int { // NOLINT(readability-function-cognitive-complexity,bugpro
114117
BOOST_TEST( arr[buf[2]] == 6 );
115118
}
116119

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)
119121
{
120122
multi::array<int, 1> const arr = {3, 1, 2, 5, 4};
121123

122124
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());
124126

125127
for(multi::index k = 0; k + 1 != order.size(); ++k) { // NOLINT(altera-unroll-loops,altera-id-dependent-backward-branch)
126128
BOOST_TEST( arr[order[k]] <= arr[order[k + 1]] );
127129
}
128130
}
129-
#endif
130131

131132
return boost::report_errors();
132133
}

0 commit comments

Comments
 (0)