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