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 // UNSUPPORTED: c++03, c++11, c++14, c++17
10 // UNSUPPORTED: libcpp-no-concepts
11 // UNSUPPORTED: gcc-10
12 // UNSUPPORTED: libcpp-has-no-incomplete-ranges
13 
14 // template<class T>
15 //   inline constexpr bool enable_borrowed_range<common_view<T>> = enable_borrowed_range<T>;
16 
17 #include <ranges>
18 #include <cassert>
19 
20 #include "test_iterators.h"
21 
22 struct View : std::ranges::view_base {
23   friend int* begin(View&);
24   friend int* begin(View const&);
25   friend sentinel_wrapper<int*> end(View&);
26   friend sentinel_wrapper<int*> end(View const&);
27 };
28 
29 struct BorrowableView : std::ranges::view_base {
30   friend int* begin(BorrowableView&);
31   friend int* begin(BorrowableView const&);
32   friend sentinel_wrapper<int*> end(BorrowableView&);
33   friend sentinel_wrapper<int*> end(BorrowableView const&);
34 };
35 
36 template<>
37 inline constexpr bool std::ranges::enable_borrowed_range<BorrowableView> = true;
38 
39 static_assert(!std::ranges::enable_borrowed_range<std::ranges::common_view<View>>);
40 static_assert( std::ranges::enable_borrowed_range<std::ranges::common_view<BorrowableView>>);
41