1 | //===----------------------------------------------------------------------===// |
2 | // |
3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
4 | // See https://llvm.org/LICENSE.txt for license information. |
5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
6 | // |
7 | //===----------------------------------------------------------------------===// |
8 | |
9 | // UNSUPPORTED: c++03, c++11, c++14, c++17 |
10 | |
11 | // <iterator> |
12 | |
13 | // template<semiregular S> |
14 | // class move_sentinel; |
15 | |
16 | #include <iterator> |
17 | |
18 | #include "test_iterators.h" |
19 | |
20 | void test() |
21 | { |
22 | // Pointer. |
23 | { |
24 | using It = int*; |
25 | static_assert( std::sentinel_for<std::move_sentinel<It>, std::move_iterator<It>>); |
26 | static_assert( std::sized_sentinel_for<std::move_sentinel<It>, std::move_iterator<It>>); |
27 | static_assert( std::sentinel_for<std::move_sentinel<sentinel_wrapper<It>>, std::move_iterator<It>>); |
28 | static_assert(!std::sized_sentinel_for<std::move_sentinel<sentinel_wrapper<It>>, std::move_iterator<It>>); |
29 | static_assert( std::sentinel_for<std::move_sentinel<sized_sentinel<It>>, std::move_iterator<It>>); |
30 | static_assert( std::sized_sentinel_for<std::move_sentinel<sized_sentinel<It>>, std::move_iterator<It>>); |
31 | } |
32 | |
33 | // `Cpp17InputIterator`. |
34 | { |
35 | using It = cpp17_input_iterator<int*>; |
36 | static_assert( std::sentinel_for<std::move_sentinel<sentinel_wrapper<It>>, std::move_iterator<It>>); |
37 | static_assert(!std::sized_sentinel_for<std::move_sentinel<sentinel_wrapper<It>>, std::move_iterator<It>>); |
38 | static_assert( std::sentinel_for<std::move_sentinel<sized_sentinel<It>>, std::move_iterator<It>>); |
39 | static_assert( std::sized_sentinel_for<std::move_sentinel<sized_sentinel<It>>, std::move_iterator<It>>); |
40 | } |
41 | |
42 | // `std::input_iterator`. |
43 | { |
44 | using It = cpp20_input_iterator<int*>; |
45 | static_assert( std::sentinel_for<std::move_sentinel<sentinel_wrapper<It>>, std::move_iterator<It>>); |
46 | static_assert(!std::sized_sentinel_for<std::move_sentinel<sentinel_wrapper<It>>, std::move_iterator<It>>); |
47 | static_assert( std::sentinel_for<std::move_sentinel<sized_sentinel<It>>, std::move_iterator<It>>); |
48 | static_assert( std::sized_sentinel_for<std::move_sentinel<sized_sentinel<It>>, std::move_iterator<It>>); |
49 | } |
50 | |
51 | // `std::forward_iterator`. |
52 | { |
53 | using It = forward_iterator<int*>; |
54 | static_assert( std::sentinel_for<std::move_sentinel<It>, std::move_iterator<It>>); |
55 | static_assert(!std::sized_sentinel_for<std::move_sentinel<It>, std::move_iterator<It>>); |
56 | static_assert( std::sentinel_for<std::move_sentinel<sentinel_wrapper<It>>, std::move_iterator<It>>); |
57 | static_assert(!std::sized_sentinel_for<std::move_sentinel<sentinel_wrapper<It>>, std::move_iterator<It>>); |
58 | static_assert( std::sentinel_for<std::move_sentinel<sized_sentinel<It>>, std::move_iterator<It>>); |
59 | static_assert( std::sized_sentinel_for<std::move_sentinel<sized_sentinel<It>>, std::move_iterator<It>>); |
60 | } |
61 | |
62 | // `std::bidirectional_iterator`. |
63 | { |
64 | using It = bidirectional_iterator<int*>; |
65 | static_assert( std::sentinel_for<std::move_sentinel<It>, std::move_iterator<It>>); |
66 | static_assert(!std::sized_sentinel_for<std::move_sentinel<It>, std::move_iterator<It>>); |
67 | static_assert( std::sentinel_for<std::move_sentinel<sentinel_wrapper<It>>, std::move_iterator<It>>); |
68 | static_assert(!std::sized_sentinel_for<std::move_sentinel<sentinel_wrapper<It>>, std::move_iterator<It>>); |
69 | static_assert( std::sentinel_for<std::move_sentinel<sized_sentinel<It>>, std::move_iterator<It>>); |
70 | static_assert( std::sized_sentinel_for<std::move_sentinel<sized_sentinel<It>>, std::move_iterator<It>>); |
71 | } |
72 | |
73 | // `std::random_access_iterator`. |
74 | { |
75 | using It = random_access_iterator<int*>; |
76 | static_assert( std::sentinel_for<std::move_sentinel<It>, std::move_iterator<It>>); |
77 | static_assert( std::sized_sentinel_for<std::move_sentinel<It>, std::move_iterator<It>>); |
78 | static_assert( std::sentinel_for<std::move_sentinel<sentinel_wrapper<It>>, std::move_iterator<It>>); |
79 | static_assert(!std::sized_sentinel_for<std::move_sentinel<sentinel_wrapper<It>>, std::move_iterator<It>>); |
80 | static_assert( std::sentinel_for<std::move_sentinel<sized_sentinel<It>>, std::move_iterator<It>>); |
81 | static_assert( std::sized_sentinel_for<std::move_sentinel<sized_sentinel<It>>, std::move_iterator<It>>); |
82 | } |
83 | |
84 | // `std::contiguous_iterator`. |
85 | { |
86 | using It = contiguous_iterator<int*>; |
87 | static_assert( std::sentinel_for<std::move_sentinel<It>, std::move_iterator<It>>); |
88 | static_assert( std::sized_sentinel_for<std::move_sentinel<It>, std::move_iterator<It>>); |
89 | static_assert( std::sentinel_for<std::move_sentinel<sentinel_wrapper<It>>, std::move_iterator<It>>); |
90 | static_assert(!std::sized_sentinel_for<std::move_sentinel<sentinel_wrapper<It>>, std::move_iterator<It>>); |
91 | static_assert( std::sentinel_for<std::move_sentinel<sized_sentinel<It>>, std::move_iterator<It>>); |
92 | static_assert( std::sized_sentinel_for<std::move_sentinel<sized_sentinel<It>>, std::move_iterator<It>>); |
93 | } |
94 | |
95 | // `std::contiguous_iterator` with the spaceship operator. |
96 | { |
97 | using It = three_way_contiguous_iterator<int*>; |
98 | static_assert( std::sentinel_for<std::move_sentinel<It>, std::move_iterator<It>>); |
99 | static_assert( std::sized_sentinel_for<std::move_sentinel<It>, std::move_iterator<It>>); |
100 | static_assert( std::sentinel_for<std::move_sentinel<sentinel_wrapper<It>>, std::move_iterator<It>>); |
101 | static_assert(!std::sized_sentinel_for<std::move_sentinel<sentinel_wrapper<It>>, std::move_iterator<It>>); |
102 | static_assert( std::sentinel_for<std::move_sentinel<sized_sentinel<It>>, std::move_iterator<It>>); |
103 | static_assert( std::sized_sentinel_for<std::move_sentinel<sized_sentinel<It>>, std::move_iterator<It>>); |
104 | } |
105 | } |
106 | |