Debian Codegraph @

libstdc++-v3/testsuite/24_iterators/headers/iterator/synopsis_c++17.cc

raw
1 // { dg-do compile { target c++17 } }
2 // { dg-require-normal-namespace "" }
3
4 // Copyright (C) 2016-2025 Free Software Foundation, Inc.
5 //
6 // This file is part of the GNU ISO C++ Library. This library is free
7 // software; you can redistribute it and/or modify it under the
8 // terms of the GNU General Public License as published by the
9 // Free Software Foundation; either version 3, or (at your option)
10 // any later version.
11
12 // This library is distributed in the hope that it will be useful,
13 // but WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 // GNU General Public License for more details.
16
17 // You should have received a copy of the GNU General Public License along
18 // with this library; see the file COPYING3. If not see
19 // <http://www.gnu.org/licenses/>.
20
21 #include <iterator>
22
23 namespace std {
24
25 // C++17 24.4.3, iterator operations:
26 template <class InputIterator, class Distance>
27 constexpr void
28 advance(InputIterator& i, Distance n);
29
30 template <class InputIterator>
31 constexpr typename iterator_traits<InputIterator>::difference_type
32 distance(InputIterator first, InputIterator last);
33
34 template <class ForwardIterator>
35 constexpr ForwardIterator
36 next(ForwardIterator x,
37 typename iterator_traits<ForwardIterator>::difference_type);
38
39 template <class BidirectionalIterator>
40 constexpr BidirectionalIterator
41 prev(BidirectionalIterator x,
42 typename iterator_traits<BidirectionalIterator>::difference_type);
43
44 // C++17 24.5, iterator adaptors:
45 template <class Iterator> class reverse_iterator;
46
47 #if __cplusplus == 201703L
48 // These operators are constrained in C++20 mode and so don't match
49 // these signatures.
50
51 template <class Iterator1, class Iterator2>
52 constexpr
53 bool operator==(const reverse_iterator<Iterator1>& x,
54 const reverse_iterator<Iterator2>& y);
55
56 template <class Iterator1, class Iterator2>
57 constexpr
58 bool operator<(const reverse_iterator<Iterator1>& x,
59 const reverse_iterator<Iterator2>& y);
60
61 template <class Iterator1, class Iterator2>
62 constexpr
63 bool operator!=(const reverse_iterator<Iterator1>& x,
64 const reverse_iterator<Iterator2>& y);
65
66 template <class Iterator1, class Iterator2>
67 constexpr
68 bool operator>(const reverse_iterator<Iterator1>& x,
69 const reverse_iterator<Iterator2>& y);
70
71 template <class Iterator1, class Iterator2>
72 constexpr
73 bool operator>=(const reverse_iterator<Iterator1>& x,
74 const reverse_iterator<Iterator2>& y);
75
76 template <class Iterator1, class Iterator2>
77 constexpr
78 bool operator<=(const reverse_iterator<Iterator1>& x,
79 const reverse_iterator<Iterator2>& y);
80 #endif // C++17
81
82 template <class Iterator1, class Iterator2>
83 constexpr auto
84 operator-(const reverse_iterator<Iterator1>& x,
85 const reverse_iterator<Iterator2>& y)
86 -> decltype(x.base() - y.base());
87
88 template <class Iterator>
89 constexpr reverse_iterator<Iterator>
90 operator+(typename reverse_iterator<Iterator>::difference_type n,
91 const reverse_iterator<Iterator>& x);
92
93 template <class Iterator>
94 constexpr reverse_iterator<Iterator> make_reverse_iterator(const Iterator&);
95
96 template <class Container> class back_insert_iterator;
97
98 template <class Container>
99 #if __cplusplus > 201703L
100 constexpr
101 #endif
102 back_insert_iterator<Container> back_inserter(Container& x);
103
104 template <class Container> class front_insert_iterator;
105
106 template <class Container>
107 #if __cplusplus > 201703L
108 constexpr
109 #endif
110 front_insert_iterator<Container> front_inserter(Container& x);
111
112 template <class Container> class insert_iterator;
113
114 #if __cplusplus == 201703L
115 // This function template is defined differently in C++20 mode and so
116 // doesn't match this signature.
117 template <class Container, class Iterator>
118 insert_iterator<Container> inserter(Container& x, Iterator i);
119
120 // These operators are constrained in C++20 mode and so don't match
121 // these signatures.
122
123 template <class Iterator> class move_iterator;
124
125 template <class Iterator1, class Iterator2>
126 constexpr
127 bool operator==(const move_iterator<Iterator1>& x,
128 const move_iterator<Iterator2>& y);
129
130 template <class Iterator1, class Iterator2>
131 constexpr
132 bool operator!=(const move_iterator<Iterator1>& x,
133 const move_iterator<Iterator2>& y);
134
135 template <class Iterator1, class Iterator2>
136 constexpr
137 bool operator<(const move_iterator<Iterator1>& x,
138 const move_iterator<Iterator2>& y);
139
140 template <class Iterator1, class Iterator2>
141 constexpr
142 bool operator<=(const move_iterator<Iterator1>& x,
143 const move_iterator<Iterator2>& y);
144
145 template <class Iterator1, class Iterator2>
146 constexpr
147 bool operator>(const move_iterator<Iterator1>& x,
148 const move_iterator<Iterator2>& y);
149
150 template <class Iterator1, class Iterator2>
151 constexpr
152 bool operator>=(const move_iterator<Iterator1>& x,
153 const move_iterator<Iterator2>& y);
154 #endif // C++17
155
156 template <class Iterator1, class Iterator2>
157 constexpr
158 auto operator-(const move_iterator<Iterator1>& x,
159 const move_iterator<Iterator2>& y)
160 -> decltype(x.base() - y.base());
161
162 template <class Iterator>
163 constexpr move_iterator<Iterator>
164 operator+(typename move_iterator<Iterator>::difference_type,
165 const move_iterator<Iterator>&);
166
167 template <class Iterator>
168 constexpr move_iterator<Iterator> make_move_iterator(const Iterator&);
169
170 // 24.6, stream iterators:
171 template <class T, class charT, class traits, class Distance>
172 class istream_iterator;
173
174 template <class T, class charT, class traits, class Distance>
175 bool operator==(const istream_iterator<T,charT,traits,Distance>& x,
176 const istream_iterator<T,charT,traits,Distance>& y);
177
178 template <class T, class charT, class traits, class Distance>
179 bool operator!=(const istream_iterator<T,charT,traits,Distance>& x,
180 const istream_iterator<T,charT,traits,Distance>& y);
181
182 template <class T, class charT, class traits>
183 class ostream_iterator;
184
185 template<class charT, class traits>
186 class istreambuf_iterator;
187
188 template <class charT, class traits>
189 bool
190 operator==(const istreambuf_iterator<charT,traits>&,
191 const istreambuf_iterator<charT,traits>&);
192
193 template <class charT, class traits>
194 bool operator!=(const istreambuf_iterator<charT,traits>&,
195 const istreambuf_iterator<charT,traits>&);
196
197 template <class charT, class traits>
198 class ostreambuf_iterator;
199 }