|
1 | 1 | #include <stdx/algorithm.hpp> |
| 2 | +#include <stdx/iterator.hpp> |
2 | 3 | #include <stdx/tuple_algorithms.hpp> |
3 | 4 | #include <stdx/tuple_destructure.hpp> |
4 | 5 |
|
@@ -61,6 +62,19 @@ TEST_CASE("n-ary for_each", "[algorithm]") { |
61 | 62 | CHECK(output == std::array{3, 6, 9, 12}); |
62 | 63 | } |
63 | 64 |
|
| 65 | +TEST_CASE("for_each with counting_iterator", "[algorithm]") { |
| 66 | + auto const input = std::array{1, 2, 3, 4}; |
| 67 | + auto output = decltype(input){}; |
| 68 | + auto [op, i] = stdx::for_each( |
| 69 | + std::cbegin(input), std::cend(input), |
| 70 | + [it = std::begin(output)](auto... ns) mutable { |
| 71 | + *it++ = (0 + ... + ns); |
| 72 | + }, |
| 73 | + stdx::counting_iterator{1}); |
| 74 | + CHECK(i == stdx::counting_iterator{5}); |
| 75 | + CHECK(output == std::array{2, 4, 6, 8}); |
| 76 | +} |
| 77 | + |
64 | 78 | TEST_CASE("unary for_each_n", "[algorithm]") { |
65 | 79 | auto const input = std::array{1, 2, 3, 4}; |
66 | 80 | auto sum = 0; |
|
0 commit comments