subrange.h 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  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. #ifndef _LIBCPP___FWD_SUBRANGE_H
  9. #define _LIBCPP___FWD_SUBRANGE_H
  10. #include <__concepts/copyable.h>
  11. #include <__config>
  12. #include <__iterator/concepts.h>
  13. #include <cstddef>
  14. #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
  15. # pragma GCC system_header
  16. #endif
  17. #if _LIBCPP_STD_VER >= 20
  18. _LIBCPP_BEGIN_NAMESPACE_STD
  19. namespace ranges {
  20. enum class subrange_kind : bool { unsized, sized };
  21. template <input_or_output_iterator _Iter, sentinel_for<_Iter> _Sent, subrange_kind _Kind>
  22. requires(_Kind == subrange_kind::sized || !sized_sentinel_for<_Sent, _Iter>)
  23. class _LIBCPP_TEMPLATE_VIS subrange;
  24. template <size_t _Index, class _Iter, class _Sent, subrange_kind _Kind>
  25. requires((_Index == 0 && copyable<_Iter>) || _Index == 1)
  26. _LIBCPP_HIDE_FROM_ABI constexpr auto get(const subrange<_Iter, _Sent, _Kind>&);
  27. template <size_t _Index, class _Iter, class _Sent, subrange_kind _Kind>
  28. requires(_Index < 2)
  29. _LIBCPP_HIDE_FROM_ABI constexpr auto get(subrange<_Iter, _Sent, _Kind>&&);
  30. } // namespace ranges
  31. using ranges::get;
  32. _LIBCPP_END_NAMESPACE_STD
  33. #endif // _LIBCPP_STD_VER >= 20
  34. #endif // _LIBCPP___FWD_SUBRANGE_H