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