xref: /llvm-project/libcxx/test/std/ranges/range.adaptors/range.drop.while/borrowed.compile.pass.cpp (revision 594fa1474f0c96da864257c0cda31b9b8381cd15)
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, class Pred>
12 //   inline constexpr bool enable_borrowed_range<drop_while_view<T, Pred>> =
13 //     enable_borrowed_range<T>;
14 
15 #include <ranges>
16 
17 struct NonBorrowed : std::ranges::view_base {
18   int* begin();
19   int* end();
20 };
21 
22 struct Borrowed : std::ranges::view_base {
23   int* begin();
24   int* end();
25 };
26 
27 struct Pred {
28   bool operator()(int) const;
29 };
30 
31 template <>
32 inline constexpr bool std::ranges::enable_borrowed_range<Borrowed> = true;
33 
34 static_assert(!std::ranges::borrowed_range<std::ranges::drop_while_view<NonBorrowed, Pred>>);
35 static_assert(std::ranges::borrowed_range<std::ranges::drop_while_view<Borrowed, Pred>>);
36