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
100e09a41bSzoecarver
110e09a41bSzoecarver // constexpr V base() const& requires copy_constructible<V>
120e09a41bSzoecarver // constexpr V base() &&
130e09a41bSzoecarver
140e09a41bSzoecarver #include <ranges>
150e09a41bSzoecarver
160e09a41bSzoecarver #include "test_macros.h"
170e09a41bSzoecarver #include "types.h"
180e09a41bSzoecarver
test()190e09a41bSzoecarver constexpr bool test() {
200e09a41bSzoecarver {
21*610ac8dbSArthur O'Dwyer std::ranges::transform_view<MoveOnlyView, PlusOne> transformView;
22*610ac8dbSArthur O'Dwyer MoveOnlyView base = std::move(transformView).base();
23*610ac8dbSArthur O'Dwyer ASSERT_SAME_TYPE(MoveOnlyView, decltype(std::move(transformView).base()));
240e09a41bSzoecarver assert(std::ranges::begin(base) == globalBuff);
250e09a41bSzoecarver }
260e09a41bSzoecarver
270e09a41bSzoecarver {
289de882fdSLouis Dionne std::ranges::transform_view<CopyableView, PlusOne> transformView;
290e09a41bSzoecarver CopyableView base1 = transformView.base();
300e09a41bSzoecarver ASSERT_SAME_TYPE(CopyableView, decltype(transformView.base()));
310e09a41bSzoecarver assert(std::ranges::begin(base1) == globalBuff);
320e09a41bSzoecarver
330e09a41bSzoecarver CopyableView base2 = std::move(transformView).base();
340e09a41bSzoecarver ASSERT_SAME_TYPE(CopyableView, decltype(std::move(transformView).base()));
350e09a41bSzoecarver assert(std::ranges::begin(base2) == globalBuff);
360e09a41bSzoecarver }
370e09a41bSzoecarver
380e09a41bSzoecarver {
399de882fdSLouis Dionne const std::ranges::transform_view<CopyableView, PlusOne> transformView;
400e09a41bSzoecarver const CopyableView base1 = transformView.base();
410e09a41bSzoecarver ASSERT_SAME_TYPE(CopyableView, decltype(transformView.base()));
420e09a41bSzoecarver assert(std::ranges::begin(base1) == globalBuff);
430e09a41bSzoecarver
440e09a41bSzoecarver const CopyableView base2 = std::move(transformView).base();
450e09a41bSzoecarver ASSERT_SAME_TYPE(CopyableView, decltype(std::move(transformView).base()));
460e09a41bSzoecarver assert(std::ranges::begin(base2) == globalBuff);
470e09a41bSzoecarver }
480e09a41bSzoecarver
490e09a41bSzoecarver return true;
500e09a41bSzoecarver }
510e09a41bSzoecarver
main(int,char **)520e09a41bSzoecarver int main(int, char**) {
530e09a41bSzoecarver test();
540e09a41bSzoecarver static_assert(test());
550e09a41bSzoecarver
560e09a41bSzoecarver return 0;
570e09a41bSzoecarver }
58