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-has-no-incomplete-ranges
11 
12 // constexpr V base() const& requires copy_constructible<V> { return base_; }
13 // constexpr V base() && { return std::move(base_); }
14 
15 #include <ranges>
16 
17 #include "test_macros.h"
18 #include "types.h"
19 
test()20 constexpr bool test() {
21   std::ranges::drop_view<MoveOnlyView> dropView1;
22   auto base1 = std::move(dropView1).base();
23   assert(std::ranges::begin(base1) == globalBuff);
24 
25   // Note: we should *not* drop two elements here.
26   std::ranges::drop_view<MoveOnlyView> dropView2(MoveOnlyView{4}, 2);
27   auto base2 = std::move(dropView2).base();
28   assert(std::ranges::begin(base2) == globalBuff + 4);
29 
30   std::ranges::drop_view<CopyableView> dropView3;
31   auto base3 = dropView3.base();
32   assert(std::ranges::begin(base3) == globalBuff);
33   auto base4 = std::move(dropView3).base();
34   assert(std::ranges::begin(base4) == globalBuff);
35 
36   return true;
37 }
38 
main(int,char **)39 int main(int, char**) {
40   test();
41   static_assert(test());
42 
43   return 0;
44 }
45