| 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 explicit elements_view(V base); |
| 12 | |
| 13 | #include <cassert> |
| 14 | #include <ranges> |
| 15 | #include <tuple> |
| 16 | #include <type_traits> |
| 17 | #include <utility> |
| 18 | |
| 19 | #include "MoveOnly.h" |
| 20 | |
| 21 | struct View : std::ranges::view_base { |
| 22 | MoveOnly mo; |
| 23 | std::tuple<int>* begin() const; |
| 24 | std::tuple<int>* end() const; |
| 25 | }; |
| 26 | |
| 27 | // Test Explicit |
| 28 | static_assert(std::is_constructible_v<std::ranges::elements_view<View, 0>, View>); |
| 29 | static_assert(!std::is_convertible_v<View, std::ranges::elements_view<View, 0>>); |
| 30 | |
| 31 | constexpr bool test() { |
| 32 | { |
| 33 | std::ranges::elements_view<View, 0> ev{View{{}, MoveOnly{5}}}; |
| 34 | assert(std::move(ev).base().mo.get() == 5); |
| 35 | } |
| 36 | |
| 37 | return true; |
| 38 | } |
| 39 | |
| 40 | int main(int, char**) { |
| 41 | test(); |
| 42 | static_assert(test()); |
| 43 | return 0; |
| 44 | } |
| 45 | |