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//
11// template<class T, size_t N>
12// inline constexpr bool enable_borrowed_range<elements_view<T, N>> =
13// enable_borrowed_range<T>;
14
15#include <ranges>
16#include <tuple>
17
18struct NonBorrowed : std::ranges::view_base {
19 std::tuple<int>* begin();
20 std::tuple<int>* end();
21};
22
23struct Borrowed : std::ranges::view_base {
24 std::tuple<int>* begin();
25 std::tuple<int>* end();
26};
27
28template <>
29inline constexpr bool std::ranges::enable_borrowed_range<Borrowed> = true;
30
31static_assert(!std::ranges::borrowed_range<std::ranges::elements_view<NonBorrowed, 0>>);
32static_assert(std::ranges::borrowed_range<std::ranges::elements_view<Borrowed, 0>>);
33

source code of libcxx/test/std/ranges/range.adaptors/range.elements/borrowed.compile.pass.cpp