| 1 | // { dg-do compile { target c++17 } } |
| 2 | |
| 3 | // Bug 110512 - C++20 random access iterators run sequentially with PSTL |
| 4 | |
| 5 | #include <algorithm> |
| 6 | #include <execution> |
| 7 | #include <ranges> |
| 8 | #include <testsuite_iterators.h> |
| 9 | |
| 10 | using InputIter = __gnu_test::input_iterator_wrapper<int>; |
| 11 | using FwdIter = __gnu_test::forward_iterator_wrapper<long>; |
| 12 | using RAIter = __gnu_test::random_access_iterator_wrapper<float>; |
| 13 | |
| 14 | template<typename... Iter> |
| 15 | constexpr bool all_random_access |
| 16 | = __pstl::__internal::__are_random_access_iterators<Iter...>::value; |
| 17 | |
| 18 | using __pstl::__internal::__are_random_access_iterators; |
| 19 | static_assert( all_random_access<RAIter> ); |
| 20 | static_assert( all_random_access<int*, RAIter, const long*> ); |
| 21 | static_assert( ! all_random_access<RAIter, FwdIter> ); |
| 22 | static_assert( ! all_random_access<FwdIter, InputIter, RAIter> ); |
| 23 | |
| 24 | #if __cpp_lib_ranges |
| 25 | using IotaIter = std::ranges::iterator_t<std::ranges::iota_view<int, int>>; |
| 26 | static_assert( std::random_access_iterator<IotaIter> ); |
| 27 | static_assert( all_random_access<IotaIter> ); |
| 28 | static_assert( all_random_access<IotaIter, RAIter> ); |
| 29 | static_assert( all_random_access<RAIter, IotaIter> ); |
| 30 | static_assert( ! all_random_access<RAIter, IotaIter, FwdIter> ); |
| 31 | #endif |