Debian Codegraph @

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

raw
1 // { dg-do compile { target c++11 } }
2
3 // Copyright (C) 2010-2025 Free Software Foundation, Inc.
4 //
5 // This file is part of the GNU ISO C++ Library. This library is free
6 // software; you can redistribute it and/or modify it under the
7 // terms of the GNU General Public License as published by the
8 // Free Software Foundation; either version 3, or (at your option)
9 // any later version.
10
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
15
16 // You should have received a copy of the GNU General Public License along
17 // with this library; see the file COPYING3. If not see
18 // <http://www.gnu.org/licenses/>.
19
20 #include <iterator>
21
22 #ifdef _GLIBCXX_RELEASE
23 // Conditional noexcept on these functions is a libstdc++ extension
24 # define NOTHROW(F) noexcept(noexcept(F))
25 #else
26 # define NOTHROW(F)
27 #endif
28
29 #if __cplusplus >= 201703L
30 # define CONSTEXPR_17 constexpr
31 #else
32 # define CONSTEXPR_17
33 #endif
34
35 #if __cplusplus >= 201402L
36 # define CONSTEXPR_14 constexpr
37 #else
38 # define CONSTEXPR_14
39 #endif
40
41 namespace std
42 {
43 template<class C>
44 CONSTEXPR_17 auto
45 begin(C& c) NOTHROW(c.begin()) -> decltype(c.begin());
46 template<class C>
47 CONSTEXPR_17 auto
48 begin(const C& c) NOTHROW(c.begin()) -> decltype(c.begin());
49
50 template<class C>
51 CONSTEXPR_17 auto
52 end(C& c) NOTHROW(c.end()) -> decltype(c.end());
53 template<class C>
54 CONSTEXPR_17 auto
55 end(const C& c) NOTHROW(c.end()) -> decltype(c.end());
56
57 template<class T, size_t N>
58 CONSTEXPR_14 T*
59 begin(T (&array)[N]) noexcept;
60 template<class T, size_t N>
61 CONSTEXPR_14 T*
62 end(T (&array)[N]) noexcept;
63
64 #if __cplusplus >= 201402L
65 template<class C>
66 constexpr auto
67 cbegin(const C& c) noexcept(noexcept(std::begin(c))) -> decltype(c.begin());
68 template<class C>
69 constexpr auto
70 cend(const C& c) noexcept(noexcept(std::end(c)))-> decltype(c.end());
71
72 template<class C>
73 CONSTEXPR_17 auto
74 rbegin(C& c) NOTHROW(c.rbegin()) -> decltype(c.rbegin());
75 template<class C>
76 CONSTEXPR_17 auto
77 rbegin(const C& c) NOTHROW(c.rbegin()) -> decltype(c.rbegin());
78
79 template<class C>
80 CONSTEXPR_17 auto
81 rend(C& c) NOTHROW(c.rend()) -> decltype(c.rend());
82 template<class C>
83 CONSTEXPR_17 auto
84 rend(const C& c) NOTHROW(c.rend()) -> decltype(c.rend());
85
86 template<class T, size_t N>
87 CONSTEXPR_17 reverse_iterator<T*>
88 rbegin(T (&array)[N]) noexcept;
89 template<class T, size_t N>
90 CONSTEXPR_17 reverse_iterator<T*>
91 rend(T (&array)[N]) noexcept;
92
93 template<class E>
94 CONSTEXPR_17 reverse_iterator<const E*>
95 rbegin(initializer_list<E>) noexcept;
96 template<class E>
97 CONSTEXPR_17 reverse_iterator<const E*>
98 rend(initializer_list<E>) noexcept;
99
100 template<class C>
101 CONSTEXPR_17 auto
102 crbegin(const C& c) NOTHROW(std::rbegin(c)) -> decltype(std::rbegin(c));
103 template<class C>
104 CONSTEXPR_17 auto
105 cend(const C& c) NOTHROW(std::rend(c)) -> decltype(std::rend(c));
106 #endif // C++14
107 }