10e09a41bSzoecarver //===----------------------------------------------------------------------===//
20e09a41bSzoecarver //
30e09a41bSzoecarver // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
40e09a41bSzoecarver // See https://llvm.org/LICENSE.txt for license information.
50e09a41bSzoecarver // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
60e09a41bSzoecarver //
70e09a41bSzoecarver //===----------------------------------------------------------------------===//
80e09a41bSzoecarver
90e09a41bSzoecarver // UNSUPPORTED: c++03, c++11, c++14, c++17
1071909de3SMark de Wever // UNSUPPORTED: libcpp-has-no-incomplete-ranges
110e09a41bSzoecarver
120e09a41bSzoecarver // constexpr V base() const& requires copy_constructible<V>
130e09a41bSzoecarver // constexpr V base() &&
140e09a41bSzoecarver
150e09a41bSzoecarver #include <ranges>
160e09a41bSzoecarver
170e09a41bSzoecarver #include "test_macros.h"
180e09a41bSzoecarver #include "types.h"
190e09a41bSzoecarver
test()200e09a41bSzoecarver constexpr bool test() {
210e09a41bSzoecarver {
22*610ac8dbSArthur O'Dwyer std::ranges::transform_view<MoveOnlyView, PlusOne> transformView;
23*610ac8dbSArthur O'Dwyer MoveOnlyView base = std::move(transformView).base();
24*610ac8dbSArthur O'Dwyer ASSERT_SAME_TYPE(MoveOnlyView, decltype(std::move(transformView).base()));
250e09a41bSzoecarver assert(std::ranges::begin(base) == globalBuff);
260e09a41bSzoecarver }
270e09a41bSzoecarver
280e09a41bSzoecarver {
299de882fdSLouis Dionne std::ranges::transform_view<CopyableView, PlusOne> transformView;
300e09a41bSzoecarver CopyableView base1 = transformView.base();
310e09a41bSzoecarver ASSERT_SAME_TYPE(CopyableView, decltype(transformView.base()));
320e09a41bSzoecarver assert(std::ranges::begin(base1) == globalBuff);
330e09a41bSzoecarver
340e09a41bSzoecarver CopyableView base2 = std::move(transformView).base();
350e09a41bSzoecarver ASSERT_SAME_TYPE(CopyableView, decltype(std::move(transformView).base()));
360e09a41bSzoecarver assert(std::ranges::begin(base2) == globalBuff);
370e09a41bSzoecarver }
380e09a41bSzoecarver
390e09a41bSzoecarver {
409de882fdSLouis Dionne const std::ranges::transform_view<CopyableView, PlusOne> transformView;
410e09a41bSzoecarver const CopyableView base1 = transformView.base();
420e09a41bSzoecarver ASSERT_SAME_TYPE(CopyableView, decltype(transformView.base()));
430e09a41bSzoecarver assert(std::ranges::begin(base1) == globalBuff);
440e09a41bSzoecarver
450e09a41bSzoecarver const CopyableView base2 = std::move(transformView).base();
460e09a41bSzoecarver ASSERT_SAME_TYPE(CopyableView, decltype(std::move(transformView).base()));
470e09a41bSzoecarver assert(std::ranges::begin(base2) == globalBuff);
480e09a41bSzoecarver }
490e09a41bSzoecarver
500e09a41bSzoecarver return true;
510e09a41bSzoecarver }
520e09a41bSzoecarver
main(int,char **)530e09a41bSzoecarver int main(int, char**) {
540e09a41bSzoecarver test();
550e09a41bSzoecarver static_assert(test());
560e09a41bSzoecarver
570e09a41bSzoecarver return 0;
580e09a41bSzoecarver }
59