File indexing completed on 2026-05-03 08:13:12
0001
0002
0003
0004
0005
0006
0007
0008
0009 #ifndef _LIBCPP___ALGORITHM_UNWRAP_RANGE_H
0010 #define _LIBCPP___ALGORITHM_UNWRAP_RANGE_H
0011
0012 #include <__algorithm/unwrap_iter.h>
0013 #include <__concepts/constructible.h>
0014 #include <__config>
0015 #include <__iterator/concepts.h>
0016 #include <__iterator/next.h>
0017 #include <__utility/declval.h>
0018 #include <__utility/move.h>
0019 #include <__utility/pair.h>
0020
0021 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
0022 # pragma GCC system_header
0023 #endif
0024
0025 _LIBCPP_PUSH_MACROS
0026 #include <__undef_macros>
0027
0028 _LIBCPP_BEGIN_NAMESPACE_STD
0029
0030
0031
0032
0033
0034 #if _LIBCPP_STD_VER >= 20
0035 template <class _Iter, class _Sent>
0036 struct __unwrap_range_impl {
0037 _LIBCPP_HIDE_FROM_ABI static constexpr auto __unwrap(_Iter __first, _Sent __sent)
0038 requires random_access_iterator<_Iter> && sized_sentinel_for<_Sent, _Iter>
0039 {
0040 auto __last = ranges::next(__first, __sent);
0041 return pair{std::__unwrap_iter(std::move(__first)), std::__unwrap_iter(std::move(__last))};
0042 }
0043
0044 _LIBCPP_HIDE_FROM_ABI static constexpr auto __unwrap(_Iter __first, _Sent __last) {
0045 return pair{std::move(__first), std::move(__last)};
0046 }
0047
0048 _LIBCPP_HIDE_FROM_ABI static constexpr auto
0049 __rewrap(_Iter __orig_iter, decltype(std::__unwrap_iter(std::move(__orig_iter))) __iter)
0050 requires random_access_iterator<_Iter> && sized_sentinel_for<_Sent, _Iter>
0051 {
0052 return std::__rewrap_iter(std::move(__orig_iter), std::move(__iter));
0053 }
0054
0055 _LIBCPP_HIDE_FROM_ABI static constexpr auto __rewrap(const _Iter&, _Iter __iter)
0056 requires(!(random_access_iterator<_Iter> && sized_sentinel_for<_Sent, _Iter>))
0057 {
0058 return __iter;
0059 }
0060 };
0061
0062 template <class _Iter>
0063 struct __unwrap_range_impl<_Iter, _Iter> {
0064 _LIBCPP_HIDE_FROM_ABI static constexpr auto __unwrap(_Iter __first, _Iter __last) {
0065 return pair{std::__unwrap_iter(std::move(__first)), std::__unwrap_iter(std::move(__last))};
0066 }
0067
0068 _LIBCPP_HIDE_FROM_ABI static constexpr auto
0069 __rewrap(_Iter __orig_iter, decltype(std::__unwrap_iter(__orig_iter)) __iter) {
0070 return std::__rewrap_iter(std::move(__orig_iter), std::move(__iter));
0071 }
0072 };
0073
0074 template <class _Iter, class _Sent>
0075 _LIBCPP_HIDE_FROM_ABI constexpr auto __unwrap_range(_Iter __first, _Sent __last) {
0076 return __unwrap_range_impl<_Iter, _Sent>::__unwrap(std::move(__first), std::move(__last));
0077 }
0078
0079 template < class _Sent, class _Iter, class _Unwrapped>
0080 _LIBCPP_HIDE_FROM_ABI constexpr _Iter __rewrap_range(_Iter __orig_iter, _Unwrapped __iter) {
0081 return __unwrap_range_impl<_Iter, _Sent>::__rewrap(std::move(__orig_iter), std::move(__iter));
0082 }
0083 #else
0084 template <class _Iter, class _Unwrapped = decltype(std::__unwrap_iter(std::declval<_Iter>()))>
0085 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR pair<_Unwrapped, _Unwrapped> __unwrap_range(_Iter __first, _Iter __last) {
0086 return std::make_pair(std::__unwrap_iter(std::move(__first)), std::__unwrap_iter(std::move(__last)));
0087 }
0088
0089 template <class _Iter, class _Unwrapped>
0090 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR _Iter __rewrap_range(_Iter __orig_iter, _Unwrapped __iter) {
0091 return std::__rewrap_iter(std::move(__orig_iter), std::move(__iter));
0092 }
0093 #endif
0094
0095 _LIBCPP_END_NAMESPACE_STD
0096
0097 _LIBCPP_POP_MACROS
0098
0099 #endif