]> git.ipfire.org Git - thirdparty/gcc.git/blob - libstdc++-v3/testsuite/24_iterators/random_access/concept.cc
Update copyright years.
[thirdparty/gcc.git] / libstdc++-v3 / testsuite / 24_iterators / random_access / concept.cc
1 // Copyright (C) 2019-2020 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-options "-std=gnu++2a" }
19 // { dg-do compile { target c++2a } }
20
21 #include <iterator>
22
23 using std::random_access_iterator;
24
25 static_assert( random_access_iterator< int* > );
26 static_assert( random_access_iterator< const int* > );
27 static_assert( random_access_iterator< void** > );
28
29 static_assert( ! random_access_iterator< int* const > );
30 static_assert( ! random_access_iterator< const int* const > );
31 static_assert( ! random_access_iterator< void** const > );
32
33 static_assert( ! random_access_iterator< void* > );
34 static_assert( ! random_access_iterator< const void* > );
35 static_assert( ! random_access_iterator< volatile void* > );
36
37 static_assert( ! random_access_iterator< void(*)() > );
38 static_assert( ! random_access_iterator< void(&)() > );
39
40 struct A;
41 static_assert( ! random_access_iterator< void(A::*)() > );
42 static_assert( ! random_access_iterator< int A::* > );
43
44 #include <array>
45 #include <deque>
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::list;
54 using std::string;
55 using std::string_view;
56 using std::vector;
57
58 struct B { };
59
60 static_assert( random_access_iterator< array<int, 1>::iterator > );
61 static_assert( random_access_iterator< array<B, 1>::const_iterator > );
62
63 static_assert( random_access_iterator< deque<int>::iterator > );
64 static_assert( random_access_iterator< deque<B>::const_iterator > );
65
66 static_assert( ! random_access_iterator< list<int>::iterator > );
67 static_assert( ! random_access_iterator< list<B>::const_iterator > );
68
69 static_assert( random_access_iterator< string::iterator > );
70 static_assert( random_access_iterator< string::const_iterator > );
71
72 static_assert( random_access_iterator< string_view::iterator > );
73 static_assert( random_access_iterator< string_view::const_iterator > );
74
75 static_assert( random_access_iterator< vector<int>::iterator > );
76 static_assert( random_access_iterator< vector<B>::const_iterator > );