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

source code of libcxx/test/std/ranges/range.adaptors/range.zip/borrowing.compile.pass.cpp