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