| 1 |
// { dg-do compile { target c++20 } } |
| 2 |
// { dg-add-options no_pch } |
| 3 |
|
| 4 |
// Verify P2520R0 changes to move_iterator's iterator_concept, which we treat |
| 5 |
// as a DR against C++20. |
| 6 |
|
| 7 |
#include <iterator> |
| 8 |
#if __cpp_lib_move_iterator_concept != 202207L |
| 9 |
# error "Feature-test macro __cpp_lib_move_iterator_concept has wrong value in <iterator>" |
| 10 |
#endif |
| 11 |
|
| 12 |
#undef __cpp_lib_move_iterator_concept |
| 13 |
#include <version> |
| 14 |
#if __cpp_lib_move_iterator_concept != 202207L |
| 15 |
# error "Feature-test macro __cpp_lib_move_iterator_concept has wrong value in <version>" |
| 16 |
#endif |
| 17 |
|
| 18 |
#include <testsuite_iterators.h> |
| 19 |
|
| 20 |
using __gnu_test::test_input_range; |
| 21 |
using __gnu_test::test_forward_range; |
| 22 |
using __gnu_test::test_bidirectional_range; |
| 23 |
using __gnu_test::test_random_access_range; |
| 24 |
|
| 25 |
using ty1 = std::move_iterator<decltype(std::declval<test_input_range<int>&>().begin())>; |
| 26 |
static_assert(std::same_as<ty1::iterator_concept, std::input_iterator_tag>); |
| 27 |
|
| 28 |
using ty2 = std::move_iterator<decltype(std::declval<test_forward_range<int>&>().begin())>; |
| 29 |
static_assert(std::same_as<ty2::iterator_concept, std::forward_iterator_tag>); |
| 30 |
|
| 31 |
using ty3 = std::move_iterator<decltype(std::declval<test_bidirectional_range<int>&>().begin())>; |
| 32 |
static_assert(std::same_as<ty3::iterator_concept, std::bidirectional_iterator_tag>); |
| 33 |
|
| 34 |
using ty4 = std::move_iterator<decltype(std::declval<test_random_access_range<int>&>().begin())>; |
| 35 |
static_assert(std::same_as<ty4::iterator_concept, std::random_access_iterator_tag>); |
| 36 |
|
| 37 |
static_assert(std::random_access_iterator<std::move_iterator<int*>>); |