@@ -29,28 +29,39 @@ struct Range : std::ranges::view_base {
2929 int * end_;
3030};
3131
32+ struct ThrowingMove {
33+ ThrowingMove () = default ;
34+ ThrowingMove (ThrowingMove&&) {}
35+ };
36+
3237template <class Iterator , bool HasNoexceptIterMove>
3338constexpr bool test () {
3439 using Sentinel = sentinel_wrapper<Iterator>;
3540 using View = minimal_view<Iterator, Sentinel>;
36- using ConcatView = std::ranges::concat_view<View>;
37- using ConcatIterator = std::ranges::iterator_t <ConcatView>;
38-
39- auto make_concat_view = [](auto begin, auto end) {
40- View view{Iterator (begin), Sentinel (Iterator (end))};
41- return ConcatView (std::move (view));
42- };
4341
44- // noexcept in case of a forward iterator
4542 {
46- int buff[] = {0 , 1 , 2 , 3 };
47- ConcatView view = make_concat_view (buff, buff + 4 );
48- ConcatIterator it = view.begin ();
49- int && result = iter_move (it);
43+ std::array<int , 5 > array1{0 , 1 , 2 , 3 , 4 };
44+ std::array<int , 5 > array2{5 , 6 , 7 , 8 , 9 };
45+
46+ View v1{Iterator (array1.data ()), Sentinel (Iterator (array1.data () + array1.size ()))};
47+ View v2{Iterator (array2.data ()), Sentinel (Iterator (array2.data () + array2.size ()))};
48+ std::ranges::concat_view view (std::move (v1), std::move (v2));
49+
50+ auto it = view.begin ();
51+ assert (std::ranges::iter_move (view.begin ()) == 0 );
5052 static_assert (noexcept (iter_move (it)) == HasNoexceptIterMove);
51- assert (&result == buff);
5253 }
5354
55+ {
56+ // iter_move may throw
57+ auto throwingMoveRange =
58+ std::views::iota (0 , 2 ) | std::views::transform ([](auto ) noexcept { return ThrowingMove{}; });
59+ std::ranges::concat_view v (throwingMoveRange);
60+ auto it = v.begin ();
61+ static_assert (!noexcept (std::ranges::iter_move (it)));
62+ }
63+
64+
5465 return true ;
5566}
5667
0 commit comments