1 // { dg-do run { target c++23 } }
5 #include <testsuite_iterators.h>
7 namespace ranges
= std::ranges
;
8 namespace views
= std::views
;
13 int x
[] = {1, 2, 3, 4, 5};
14 auto v
= x
| views::filter([](int) { return true; });
15 static_assert( ranges::bidirectional_range
<decltype(v
)>
16 && !ranges::random_access_range
<decltype(v
)> );
17 auto f
= [](int& x
, int&& acc
) {
20 VERIFY( ranges::fold_right(v
, 0, f
) == 129 );
21 VERIFY( ranges::fold_right(v
, 1, f
) == 161 );
22 VERIFY( ranges::fold_right(v
.begin(), v
.begin(), 1, f
) == 1 );
24 VERIFY( ranges::fold_right_last(v
, f
).value() == 129 );
25 VERIFY( !ranges::fold_right_last(v
.begin(), v
.begin(), f
).has_value() );
33 double x
[] = {0.5, 0.25, 0.125, 0.125};
34 VERIFY( ranges::fold_right(x
, 0, std::plus
{}) == 1.0 );
42 static_assert(test01());
43 static_assert(test02());