libstdc++: Implement P2520R0 changes to move_iterator's iterator_concept
[official-gcc.git] / libstdc++-v3 / testsuite / 24_iterators / move_iterator / p2520r0.cc
blob883d6cc09e00f96f0df523febdc5d33459180a8b
1 // { dg-options "-std=gnu++20" }
2 // { dg-do compile { target c++20 } }
4 // Verify P2520R0 changes to move_iterator's iterator_concept, which we treat
5 // as a DR against C++20.
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
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
18 #include <testsuite_iterators.h>
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;
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>);
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>);
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>);
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>);
37 static_assert(std::random_access_iterator<std::move_iterator<int*>>);