File indexing completed on 2026-05-03 08:14:02
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010 #ifndef _LIBCPP___RANGES_RBEGIN_H
0011 #define _LIBCPP___RANGES_RBEGIN_H
0012
0013 #include <__concepts/class_or_enum.h>
0014 #include <__concepts/same_as.h>
0015 #include <__config>
0016 #include <__iterator/concepts.h>
0017 #include <__iterator/readable_traits.h>
0018 #include <__iterator/reverse_iterator.h>
0019 #include <__ranges/access.h>
0020 #include <__type_traits/decay.h>
0021 #include <__type_traits/is_reference.h>
0022 #include <__type_traits/remove_cvref.h>
0023 #include <__type_traits/remove_reference.h>
0024 #include <__utility/auto_cast.h>
0025
0026 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
0027 # pragma GCC system_header
0028 #endif
0029
0030 _LIBCPP_BEGIN_NAMESPACE_STD
0031
0032 #if _LIBCPP_STD_VER >= 20
0033
0034
0035
0036 namespace ranges {
0037 namespace __rbegin {
0038 template <class _Tp>
0039 concept __member_rbegin = __can_borrow<_Tp> && requires(_Tp&& __t) {
0040 { _LIBCPP_AUTO_CAST(__t.rbegin()) } -> input_or_output_iterator;
0041 };
0042
0043 void rbegin() = delete;
0044
0045 template <class _Tp>
0046 concept __unqualified_rbegin =
0047 !__member_rbegin<_Tp> && __can_borrow<_Tp> && __class_or_enum<remove_cvref_t<_Tp>> && requires(_Tp&& __t) {
0048 { _LIBCPP_AUTO_CAST(rbegin(__t)) } -> input_or_output_iterator;
0049 };
0050
0051 template <class _Tp>
0052 concept __can_reverse =
0053 __can_borrow<_Tp> && !__member_rbegin<_Tp> && !__unqualified_rbegin<_Tp> && requires(_Tp&& __t) {
0054 { ranges::begin(__t) } -> same_as<decltype(ranges::end(__t))>;
0055 { ranges::begin(__t) } -> bidirectional_iterator;
0056 };
0057
0058 struct __fn {
0059 template <class _Tp>
0060 requires __member_rbegin<_Tp>
0061 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Tp&& __t) const
0062 noexcept(noexcept(_LIBCPP_AUTO_CAST(__t.rbegin()))) {
0063 return _LIBCPP_AUTO_CAST(__t.rbegin());
0064 }
0065
0066 template <class _Tp>
0067 requires __unqualified_rbegin<_Tp>
0068 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Tp&& __t) const
0069 noexcept(noexcept(_LIBCPP_AUTO_CAST(rbegin(__t)))) {
0070 return _LIBCPP_AUTO_CAST(rbegin(__t));
0071 }
0072
0073 template <class _Tp>
0074 requires __can_reverse<_Tp>
0075 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Tp&& __t) const noexcept(noexcept(ranges::end(__t))) {
0076 return std::make_reverse_iterator(ranges::end(__t));
0077 }
0078
0079 void operator()(auto&&) const = delete;
0080 };
0081 }
0082
0083 inline namespace __cpo {
0084 inline constexpr auto rbegin = __rbegin::__fn{};
0085 }
0086 }
0087
0088
0089
0090 namespace ranges {
0091 namespace __crbegin {
0092 struct __fn {
0093 template <class _Tp>
0094 requires is_lvalue_reference_v<_Tp&&>
0095 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Tp&& __t) const
0096 noexcept(noexcept(ranges::rbegin(static_cast<const remove_reference_t<_Tp>&>(__t))))
0097 -> decltype(ranges::rbegin(static_cast<const remove_reference_t<_Tp>&>(__t))) {
0098 return ranges::rbegin(static_cast<const remove_reference_t<_Tp>&>(__t));
0099 }
0100
0101 template <class _Tp>
0102 requires is_rvalue_reference_v<_Tp&&>
0103 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Tp&& __t) const
0104 noexcept(noexcept(ranges::rbegin(static_cast<const _Tp&&>(__t))))
0105 -> decltype(ranges::rbegin(static_cast<const _Tp&&>(__t))) {
0106 return ranges::rbegin(static_cast<const _Tp&&>(__t));
0107 }
0108 };
0109 }
0110
0111 inline namespace __cpo {
0112 inline constexpr auto crbegin = __crbegin::__fn{};
0113 }
0114 }
0115
0116 #endif
0117
0118 _LIBCPP_END_NAMESPACE_STD
0119
0120 #endif