| 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 <initializer_list> |
| 16 | |
| 17 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 18 | # pragma GCC system_header |
| 19 | #endif |
| 20 | |
| 21 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 22 | |
| 23 | #if _LIBCPP_STD_VER >= 14 |
| 24 | |
| 25 | template <class _Tp, size_t _Np> |
| 26 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 reverse_iterator<_Tp*> rbegin(_Tp (&__array)[_Np]) { |
| 27 | return reverse_iterator<_Tp*>(__array + _Np); |
| 28 | } |
| 29 | |
| 30 | template <class _Tp, size_t _Np> |
| 31 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 reverse_iterator<_Tp*> rend(_Tp (&__array)[_Np]) { |
| 32 | return reverse_iterator<_Tp*>(__array); |
| 33 | } |
| 34 | |
| 35 | template <class _Ep> |
| 36 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 reverse_iterator<const _Ep*> rbegin(initializer_list<_Ep> __il) { |
| 37 | return reverse_iterator<const _Ep*>(__il.end()); |
| 38 | } |
| 39 | |
| 40 | template <class _Ep> |
| 41 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 reverse_iterator<const _Ep*> rend(initializer_list<_Ep> __il) { |
| 42 | return reverse_iterator<const _Ep*>(__il.begin()); |
| 43 | } |
| 44 | |
| 45 | template <class _Cp> |
| 46 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 auto rbegin(_Cp& __c) -> decltype(__c.rbegin()) { |
| 47 | return __c.rbegin(); |
| 48 | } |
| 49 | |
| 50 | template <class _Cp> |
| 51 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 auto rbegin(const _Cp& __c) -> decltype(__c.rbegin()) { |
| 52 | return __c.rbegin(); |
| 53 | } |
| 54 | |
| 55 | template <class _Cp> |
| 56 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 auto rend(_Cp& __c) -> decltype(__c.rend()) { |
| 57 | return __c.rend(); |
| 58 | } |
| 59 | |
| 60 | template <class _Cp> |
| 61 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 auto rend(const _Cp& __c) -> decltype(__c.rend()) { |
| 62 | return __c.rend(); |
| 63 | } |
| 64 | |
| 65 | template <class _Cp> |
| 66 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 auto crbegin(const _Cp& __c) -> decltype(std::rbegin(__c)) { |
| 67 | return std::rbegin(__c); |
| 68 | } |
| 69 | |
| 70 | template <class _Cp> |
| 71 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 auto crend(const _Cp& __c) -> decltype(std::rend(__c)) { |
| 72 | return std::rend(__c); |
| 73 | } |
| 74 | |
| 75 | #endif // _LIBCPP_STD_VER >= 14 |
| 76 | |
| 77 | _LIBCPP_END_NAMESPACE_STD |
| 78 | |
| 79 | #endif // _LIBCPP___ITERATOR_REVERSE_ACCESS_H |
| 80 |