| 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 iterator(iterator_t<Base> current); |
| 12 | |
| 13 | #include <cassert> |
| 14 | #include <ranges> |
| 15 | #include <tuple> |
| 16 | |
| 17 | #include "../types.h" |
| 18 | |
| 19 | // Test explicit |
| 20 | using BaseIter = std::tuple<int>*; |
| 21 | using ElementsIter = std::ranges::iterator_t<std::ranges::elements_view<std::ranges::subrange<BaseIter, BaseIter>, 0>>; |
| 22 | |
| 23 | static_assert(std::is_constructible_v<ElementsIter, BaseIter>); |
| 24 | static_assert(!std::is_convertible_v<BaseIter, ElementsIter>); |
| 25 | |
| 26 | struct TracedMoveIter : IterBase<TracedMoveIter>{ |
| 27 | bool moved = false; |
| 28 | |
| 29 | constexpr TracedMoveIter() = default; |
| 30 | constexpr TracedMoveIter(const TracedMoveIter&) = default; |
| 31 | constexpr TracedMoveIter(TracedMoveIter&&) : moved{true} {} |
| 32 | constexpr TracedMoveIter& operator=(TracedMoveIter&&) = default; |
| 33 | constexpr TracedMoveIter& operator=(const TracedMoveIter&) = default; |
| 34 | }; |
| 35 | |
| 36 | struct TracedMoveView : std::ranges::view_base { |
| 37 | TracedMoveIter begin() const; |
| 38 | TracedMoveIter end() const; |
| 39 | }; |
| 40 | |
| 41 | constexpr bool test() { |
| 42 | using Iter = std::ranges::iterator_t<std::ranges::elements_view<TracedMoveView, 0>>; |
| 43 | Iter iter{TracedMoveIter{}}; |
| 44 | assert(iter.base().moved); |
| 45 | |
| 46 | return true; |
| 47 | } |
| 48 | |
| 49 | int main(int, char**) { |
| 50 | test(); |
| 51 | static_assert(test()); |
| 52 | |
| 53 | return 0; |
| 54 | } |
| 55 | |