| 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 | #if _LIBCPP_STD_VER >= 14 |
| 22 | |
| 23 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 24 | |
| 25 | template <class _Tp, size_t _Np> |
| 26 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 reverse_iterator<_Tp*> |
| 27 | rbegin(_Tp (&__array)[_Np]) noexcept { |
| 28 | return reverse_iterator<_Tp*>(__array + _Np); |
| 29 | } |
| 30 | |
| 31 | template <class _Tp, size_t _Np> |
| 32 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 reverse_iterator<_Tp*> |
| 33 | rend(_Tp (&__array)[_Np]) noexcept { |
| 34 | return reverse_iterator<_Tp*>(__array); |
| 35 | } |
| 36 | |
| 37 | template <class _Ep> |
| 38 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 reverse_iterator<const _Ep*> |
| 39 | rbegin(initializer_list<_Ep> __il) noexcept { |
| 40 | return reverse_iterator<const _Ep*>(__il.end()); |
| 41 | } |
| 42 | |
| 43 | template <class _Ep> |
| 44 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 reverse_iterator<const _Ep*> |
| 45 | rend(initializer_list<_Ep> __il) noexcept { |
| 46 | return reverse_iterator<const _Ep*>(__il.begin()); |
| 47 | } |
| 48 | |
| 49 | template <class _Cp> |
| 50 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 auto rbegin(_Cp& __c) // |
| 51 | noexcept(noexcept(__c.rbegin())) // |
| 52 | -> decltype(/*-*/ __c.rbegin()) { |
| 53 | return /*--------*/ __c.rbegin(); |
| 54 | } |
| 55 | |
| 56 | template <class _Cp> |
| 57 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 auto rbegin(const _Cp& __c) // |
| 58 | noexcept(noexcept(__c.rbegin())) // |
| 59 | -> decltype(/*-*/ __c.rbegin()) { |
| 60 | return /*--------*/ __c.rbegin(); |
| 61 | } |
| 62 | |
| 63 | template <class _Cp> |
| 64 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 auto rend(_Cp& __c) // |
| 65 | noexcept(noexcept(__c.rend())) // |
| 66 | -> decltype(/*-*/ __c.rend()) { |
| 67 | return /*--------*/ __c.rend(); |
| 68 | } |
| 69 | |
| 70 | template <class _Cp> |
| 71 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 auto rend(const _Cp& __c) // |
| 72 | noexcept(noexcept(__c.rend())) // |
| 73 | -> decltype(/*-*/ __c.rend()) { |
| 74 | return /*--------*/ __c.rend(); |
| 75 | } |
| 76 | |
| 77 | template <class _Cp> |
| 78 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 auto crbegin(const _Cp& __c) // |
| 79 | noexcept(noexcept(std::rbegin(__c))) // |
| 80 | -> decltype(/*-*/ std::rbegin(__c)) { |
| 81 | return /*--------*/ std::rbegin(__c); |
| 82 | } |
| 83 | |
| 84 | template <class _Cp> |
| 85 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 auto crend(const _Cp& __c) // |
| 86 | noexcept(noexcept(std::rend(__c))) // |
| 87 | -> decltype(/*-*/ std::rend(__c)) { |
| 88 | return /*--------*/ std::rend(__c); |
| 89 | } |
| 90 | |
| 91 | _LIBCPP_END_NAMESPACE_STD |
| 92 | |
| 93 | #endif // _LIBCPP_STD_VER >= 14 |
| 94 | |
| 95 | #endif // _LIBCPP___ITERATOR_REVERSE_ACCESS_H |
| 96 |