]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/llvm-project/libcxx/include/__iterator/reverse_access.h
zfs: merge openzfs/zfs@6a6bd4939 (zfs-2.1-release) into stable/13
[FreeBSD/FreeBSD.git] / contrib / llvm-project / libcxx / include / __iterator / reverse_access.h
1 // -*- C++ -*-
2 //===----------------------------------------------------------------------===//
3 //
4 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
5 // See https://llvm.org/LICENSE.txt for license information.
6 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //
8 //===----------------------------------------------------------------------===//
9
10 #ifndef _LIBCPP___ITERATOR_REVERSE_ACCESS_H
11 #define _LIBCPP___ITERATOR_REVERSE_ACCESS_H
12
13 #include <__config>
14 #include <__iterator/reverse_iterator.h>
15 #include <cstddef>
16 #include <initializer_list>
17
18 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
19 #pragma GCC system_header
20 #endif
21
22 _LIBCPP_BEGIN_NAMESPACE_STD
23
24 #if !defined(_LIBCPP_CXX03_LANG)
25
26 #if _LIBCPP_STD_VER > 11
27
28 template <class _Tp, size_t _Np>
29 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
30 reverse_iterator<_Tp*> rbegin(_Tp (&__array)[_Np])
31 {
32     return reverse_iterator<_Tp*>(__array + _Np);
33 }
34
35 template <class _Tp, size_t _Np>
36 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
37 reverse_iterator<_Tp*> rend(_Tp (&__array)[_Np])
38 {
39     return reverse_iterator<_Tp*>(__array);
40 }
41
42 template <class _Ep>
43 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
44 reverse_iterator<const _Ep*> rbegin(initializer_list<_Ep> __il)
45 {
46     return reverse_iterator<const _Ep*>(__il.end());
47 }
48
49 template <class _Ep>
50 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
51 reverse_iterator<const _Ep*> rend(initializer_list<_Ep> __il)
52 {
53     return reverse_iterator<const _Ep*>(__il.begin());
54 }
55
56 template <class _Cp>
57 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
58 auto rbegin(_Cp& __c) -> decltype(__c.rbegin())
59 {
60     return __c.rbegin();
61 }
62
63 template <class _Cp>
64 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
65 auto rbegin(const _Cp& __c) -> decltype(__c.rbegin())
66 {
67     return __c.rbegin();
68 }
69
70 template <class _Cp>
71 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
72 auto rend(_Cp& __c) -> decltype(__c.rend())
73 {
74     return __c.rend();
75 }
76
77 template <class _Cp>
78 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
79 auto rend(const _Cp& __c) -> decltype(__c.rend())
80 {
81     return __c.rend();
82 }
83
84 template <class _Cp>
85 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
86 auto crbegin(const _Cp& __c) -> decltype(_VSTD::rbegin(__c))
87 {
88     return _VSTD::rbegin(__c);
89 }
90
91 template <class _Cp>
92 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
93 auto crend(const _Cp& __c) -> decltype(_VSTD::rend(__c))
94 {
95     return _VSTD::rend(__c);
96 }
97
98 #endif
99
100 #endif // !defined(_LIBCPP_CXX03_LANG)
101
102 _LIBCPP_END_NAMESPACE_STD
103
104 #endif // _LIBCPP___ITERATOR_REVERSE_ACCESS_H