]> git.ipfire.org Git - thirdparty/gcc.git/blob - libstdc++-v3/testsuite/24_iterators/input/concept.cc
38927571f1ceeb4655059bf6bf6e0c2b075ac146
[thirdparty/gcc.git] / libstdc++-v3 / testsuite / 24_iterators / input / concept.cc
1 // Copyright (C) 2019-2024 Free Software Foundation, Inc.
2 //
3 // This file is part of the GNU ISO C++ Library. This library is free
4 // software; you can redistribute it and/or modify it under the
5 // terms of the GNU General Public License as published by the
6 // Free Software Foundation; either version 3, or (at your option)
7 // any later version.
8
9 // This library is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU General Public License for more details.
13
14 // You should have received a copy of the GNU General Public License along
15 // with this library; see the file COPYING3. If not see
16 // <http://www.gnu.org/licenses/>.
17
18 // { dg-do compile { target c++20 } }
19
20 #include <iterator>
21
22 using std::input_iterator;
23
24 static_assert( input_iterator< int* > );
25 static_assert( input_iterator< const int* > );
26 static_assert( input_iterator< void** > );
27
28 static_assert( ! input_iterator< int* const > );
29 static_assert( ! input_iterator< const int* const > );
30 static_assert( ! input_iterator< void** const > );
31
32 static_assert( ! input_iterator< void* > );
33 static_assert( ! input_iterator< const void* > );
34 static_assert( ! input_iterator< volatile void* > );
35
36 static_assert( ! input_iterator< void(*)() > );
37 static_assert( ! input_iterator< void(&)() > );
38
39 struct A;
40 static_assert( ! input_iterator< void(A::*)() > );
41 static_assert( ! input_iterator< int A::* > );
42
43 #include <array>
44 #include <deque>
45 #include <forward_list>
46 #include <list>
47 #include <string>
48 #include <string_view>
49 #include <vector>
50
51 using std::array;
52 using std::deque;
53 using std::forward_list;
54 using std::list;
55 using std::string;
56 using std::string_view;
57 using std::vector;
58
59 struct B { };
60
61 static_assert( input_iterator< array<int, 1>::iterator > );
62 static_assert( input_iterator< array<B, 1>::const_iterator > );
63
64 static_assert( input_iterator< deque<int>::iterator > );
65 static_assert( input_iterator< deque<B>::const_iterator > );
66
67 static_assert( input_iterator< forward_list<int>::iterator > );
68 static_assert( input_iterator< forward_list<B>::const_iterator > );
69
70 static_assert( input_iterator< list<int>::iterator > );
71 static_assert( input_iterator< list<B>::const_iterator > );
72
73 static_assert( input_iterator< string::iterator > );
74 static_assert( input_iterator< string::const_iterator > );
75
76 static_assert( input_iterator< string_view::iterator > );
77 static_assert( input_iterator< string_view::const_iterator > );
78
79 static_assert( input_iterator< vector<int>::iterator > );
80 static_assert( input_iterator< vector<B>::const_iterator > );
81
82 #include <streambuf>
83
84 using std::istreambuf_iterator;
85 using std::ostreambuf_iterator;
86
87 static_assert( input_iterator< istreambuf_iterator<char> > );
88 static_assert( ! input_iterator< ostreambuf_iterator<char> > );