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 //===----------------------------------------------------------------------===//
9 #ifndef LIBCXX_TEST_SUPPORT_TEST_RANGE_H
10 #define LIBCXX_TEST_SUPPORT_TEST_RANGE_H
15 #include "test_iterators.h"
18 #error "test/support/test_range.h" can only be included in builds supporting ranges
22 bool operator==(std::input_or_output_iterator
auto const&) const;
25 template <template <class...> class I
>
26 requires
std::input_or_output_iterator
<I
<int*> >
29 I
<int const*> begin() const;
34 template <template <class...> class I
>
35 requires
std::input_or_output_iterator
<I
<int*> >
36 struct test_non_const_range
{
41 template <template <class...> class I
>
42 requires
std::input_or_output_iterator
<I
<int*> >
43 struct test_common_range
{
45 I
<int const*> begin() const;
47 I
<int const*> end() const;
50 template <template <class...> class I
>
51 requires
std::input_or_output_iterator
<I
<int*> >
52 struct test_non_const_common_range
{
57 template <template <class...> class I
>
58 requires
std::input_or_output_iterator
<I
<int*> >
59 struct test_view
: std::ranges::view_base
{
61 I
<int const*> begin() const;
66 struct BorrowedRange
{
69 BorrowedRange(BorrowedRange
&&) = delete;
71 template<> inline constexpr bool std::ranges::enable_borrowed_range
<BorrowedRange
> = true;
72 static_assert(!std::ranges::view
<BorrowedRange
>);
73 static_assert(std::ranges::borrowed_range
<BorrowedRange
>);
75 using BorrowedView
= std::ranges::empty_view
<int>;
76 static_assert(std::ranges::view
<BorrowedView
>);
77 static_assert(std::ranges::borrowed_range
<BorrowedView
>);
79 using NonBorrowedView
= std::ranges::single_view
<int>;
80 static_assert(std::ranges::view
<NonBorrowedView
>);
81 static_assert(!std::ranges::borrowed_range
<NonBorrowedView
>);
83 #endif // LIBCXX_TEST_SUPPORT_TEST_RANGE_H