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, c++20 |
10 | |
11 | // template<class... Views> |
12 | // inline constexpr bool enable_borrowed_range<zip_view<Views...>> = |
13 | // (enable_borrowed_range<Views> && ...); |
14 | |
15 | #include <ranges> |
16 | |
17 | struct Borrowed : std::ranges::view_base { |
18 | int* begin() const; |
19 | int* end() const; |
20 | }; |
21 | |
22 | template <> |
23 | inline constexpr bool std::ranges::enable_borrowed_range<Borrowed> = true; |
24 | |
25 | static_assert(std::ranges::borrowed_range<Borrowed>); |
26 | |
27 | struct NonBorrowed : std::ranges::view_base { |
28 | int* begin() const; |
29 | int* end() const; |
30 | }; |
31 | static_assert(!std::ranges::borrowed_range<NonBorrowed>); |
32 | |
33 | // test borrowed_range |
34 | static_assert(std::ranges::borrowed_range<std::ranges::zip_view<Borrowed>>); |
35 | static_assert(std::ranges::borrowed_range<std::ranges::zip_view<Borrowed, Borrowed>>); |
36 | static_assert(!std::ranges::borrowed_range<std::ranges::zip_view<Borrowed, NonBorrowed>>); |
37 | static_assert(!std::ranges::borrowed_range<std::ranges::zip_view<NonBorrowed>>); |
38 | static_assert(!std::ranges::borrowed_range<std::ranges::zip_view<NonBorrowed, NonBorrowed>>); |
39 | |