[clang][modules] Don't prevent translation of FW_Private includes when explicitly...
[llvm-project.git] / libcxx / test / support / test_range.h
blobeea8ce16ce7fa3a9bb086f98621654277cfa1c2b
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 //===----------------------------------------------------------------------===//
9 #ifndef LIBCXX_TEST_SUPPORT_TEST_RANGE_H
10 #define LIBCXX_TEST_SUPPORT_TEST_RANGE_H
12 #include <iterator>
13 #include <ranges>
15 #include "test_iterators.h"
17 #if TEST_STD_VER < 17
18 #error "test/support/test_range.h" can only be included in builds supporting ranges
19 #endif
21 struct sentinel {
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*> >
27 struct test_range {
28 I<int*> begin();
29 I<int const*> begin() const;
30 sentinel end();
31 sentinel end() const;
34 template <template <class...> class I>
35 requires std::input_or_output_iterator<I<int*> >
36 struct test_non_const_range {
37 I<int*> begin();
38 sentinel end();
41 template <template <class...> class I>
42 requires std::input_or_output_iterator<I<int*> >
43 struct test_common_range {
44 I<int*> begin();
45 I<int const*> begin() const;
46 I<int*> end();
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 {
53 I<int*> begin();
54 I<int*> end();
57 template <template <class...> class I>
58 requires std::input_or_output_iterator<I<int*> >
59 struct test_view : std::ranges::view_base {
60 I<int*> begin();
61 I<int const*> begin() const;
62 sentinel end();
63 sentinel end() const;
66 struct BorrowedRange {
67 int *begin() const;
68 int *end() const;
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