Hui Xie | 9446182 | 2022-11-04 11:53:38 | [diff] [blame] | 1 | //===---------------------------------------------------------------------===// |
| 2 | // |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 4 | // See https://llvm.org/LICENSE.txt for license information. |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
| 6 | // |
| 7 | //===---------------------------------------------------------------------===// |
| 8 | |
| 9 | #ifndef _LIBCPP___FWD_SUBRANGE_H |
| 10 | #define _LIBCPP___FWD_SUBRANGE_H |
| 11 | |
Nikolas Klauser | f9d6d6f | 2024-02-12 07:32:28 | [diff] [blame] | 12 | #include <__concepts/copyable.h> |
Hui Xie | 9446182 | 2022-11-04 11:53:38 | [diff] [blame] | 13 | #include <__config> |
Louis Dionne | d6832a6 | 2024-09-05 12:28:33 | [diff] [blame] | 14 | #include <__cstddef/size_t.h> |
Nikolas Klauser | f9d6d6f | 2024-02-12 07:32:28 | [diff] [blame] | 15 | #include <__iterator/concepts.h> |
Hui Xie | 9446182 | 2022-11-04 11:53:38 | [diff] [blame] | 16 | |
| 17 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 18 | # pragma GCC system_header |
| 19 | #endif |
| 20 | |
| 21 | #if _LIBCPP_STD_VER >= 20 |
| 22 | |
Hui Xie | 9446182 | 2022-11-04 11:53:38 | [diff] [blame] | 23 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 24 | |
| 25 | namespace ranges { |
| 26 | |
Nikolas Klauser | 3583bf3 | 2023-08-19 22:15:47 | [diff] [blame] | 27 | enum class subrange_kind : bool { unsized, sized }; |
Hui Xie | 9446182 | 2022-11-04 11:53:38 | [diff] [blame] | 28 | |
| 29 | template <input_or_output_iterator _Iter, sentinel_for<_Iter> _Sent, subrange_kind _Kind> |
| 30 | requires(_Kind == subrange_kind::sized || !sized_sentinel_for<_Sent, _Iter>) |
Nikolas Klauser | af9c04f | 2025-04-09 21:47:57 | [diff] [blame] | 31 | class subrange; |
Hui Xie | 9446182 | 2022-11-04 11:53:38 | [diff] [blame] | 32 | |
Nikolas Klauser | f9d6d6f | 2024-02-12 07:32:28 | [diff] [blame] | 33 | template <size_t _Index, class _Iter, class _Sent, subrange_kind _Kind> |
| 34 | requires((_Index == 0 && copyable<_Iter>) || _Index == 1) |
| 35 | _LIBCPP_HIDE_FROM_ABI constexpr auto get(const subrange<_Iter, _Sent, _Kind>&); |
| 36 | |
| 37 | template <size_t _Index, class _Iter, class _Sent, subrange_kind _Kind> |
| 38 | requires(_Index < 2) |
| 39 | _LIBCPP_HIDE_FROM_ABI constexpr auto get(subrange<_Iter, _Sent, _Kind>&&); |
| 40 | |
Hui Xie | 9446182 | 2022-11-04 11:53:38 | [diff] [blame] | 41 | } // namespace ranges |
| 42 | |
Nikolas Klauser | f9d6d6f | 2024-02-12 07:32:28 | [diff] [blame] | 43 | using ranges::get; |
| 44 | |
Hui Xie | 9446182 | 2022-11-04 11:53:38 | [diff] [blame] | 45 | _LIBCPP_END_NAMESPACE_STD |
| 46 | |
| 47 | #endif // _LIBCPP_STD_VER >= 20 |
| 48 | |
| 49 | #endif // _LIBCPP___FWD_SUBRANGE_H |