1 //===----------------------------------------------------------------------===//
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
7 //===----------------------------------------------------------------------===//
8 #ifndef LIBCXX_TEST_SUPPORT_TEST_RANGE_H
9 #define LIBCXX_TEST_SUPPORT_TEST_RANGE_H
14 #include "test_iterators.h"
16 #if _LIBCPP_STD_VER < 17
17 #error "test/support/test_range.h" can only be included in builds supporting ranges
21 bool operator==(std::input_or_output_iterator
auto const&) const;
24 template <template <class...> class I
>
25 requires
std::input_or_output_iterator
<I
<int*> >
28 I
<int const*> begin() const;
33 template <template <class...> class I
>
34 requires
std::input_or_output_iterator
<I
<int*> >
35 struct test_non_const_range
{
40 template <template <class...> class I
>
41 requires
std::input_or_output_iterator
<I
<int*> >
42 struct test_common_range
{
44 I
<int const*> begin() const;
46 I
<int const*> end() const;
49 template <template <class...> class I
>
50 requires
std::input_or_output_iterator
<I
<int*> >
51 struct test_non_const_common_range
{
56 template <template <class...> class I
>
57 requires
std::input_or_output_iterator
<I
<int*> >
58 struct test_view
: std::ranges::view_base
{
60 I
<int const*> begin() const;
65 struct BorrowedRange
{
68 BorrowedRange(BorrowedRange
&&) = delete;
70 template<> inline constexpr bool std::ranges::enable_borrowed_range
<BorrowedRange
> = true;
71 static_assert(!std::ranges::view
<BorrowedRange
>);
72 static_assert(std::ranges::borrowed_range
<BorrowedRange
>);
74 using BorrowedView
= std::ranges::empty_view
<int>;
75 static_assert(std::ranges::view
<BorrowedView
>);
76 static_assert(std::ranges::borrowed_range
<BorrowedView
>);
78 using NonBorrowedView
= std::ranges::single_view
<int>;
79 static_assert(std::ranges::view
<NonBorrowedView
>);
80 static_assert(!std::ranges::borrowed_range
<NonBorrowedView
>);
82 #endif // LIBCXX_TEST_SUPPORT_TEST_RANGE_H