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 | // constexpr V base() const& requires copy_constructible<V> |
12 | // constexpr V base() && |
13 | |
14 | #include <ranges> |
15 | |
16 | #include "test_macros.h" |
17 | #include "types.h" |
18 | |
19 | constexpr bool test() { |
20 | { |
21 | std::ranges::transform_view<MoveOnlyView, PlusOne> transformView; |
22 | MoveOnlyView base = std::move(transformView).base(); |
23 | ASSERT_SAME_TYPE(MoveOnlyView, decltype(std::move(transformView).base())); |
24 | assert(std::ranges::begin(base) == globalBuff); |
25 | } |
26 | |
27 | { |
28 | std::ranges::transform_view<CopyableView, PlusOne> transformView; |
29 | CopyableView base1 = transformView.base(); |
30 | ASSERT_SAME_TYPE(CopyableView, decltype(transformView.base())); |
31 | assert(std::ranges::begin(base1) == globalBuff); |
32 | |
33 | CopyableView base2 = std::move(transformView).base(); |
34 | ASSERT_SAME_TYPE(CopyableView, decltype(std::move(transformView).base())); |
35 | assert(std::ranges::begin(base2) == globalBuff); |
36 | } |
37 | |
38 | { |
39 | const std::ranges::transform_view<CopyableView, PlusOne> transformView; |
40 | const CopyableView base1 = transformView.base(); |
41 | ASSERT_SAME_TYPE(CopyableView, decltype(transformView.base())); |
42 | assert(std::ranges::begin(base1) == globalBuff); |
43 | |
44 | const CopyableView base2 = std::move(transformView).base(); |
45 | ASSERT_SAME_TYPE(CopyableView, decltype(std::move(transformView).base())); |
46 | assert(std::ranges::begin(base2) == globalBuff); |
47 | } |
48 | |
49 | return true; |
50 | } |
51 | |
52 | int main(int, char**) { |
53 | test(); |
54 | static_assert(test()); |
55 | |
56 | return 0; |
57 | } |
58 | |