@@ -64,34 +64,40 @@ TEST_CONSTEXPR_CXX20 bool test() {
64
64
const unsigned s = sizeof (ia) / sizeof (ia[0 ]);
65
65
66
66
{
67
- auto f = for_each_test (0 );
68
- Iter it = std::for_each_n (Iter (ia), 0 , std::ref (f));
67
+ unsigned count = 0 ;
68
+ Iter it = std::for_each_n (Iter (ia), 0 , [&count](int & i) mutable {
69
+ ++i;
70
+ ++count;
71
+ });
69
72
assert (it == Iter (ia));
70
- assert (f. count == 0 );
73
+ assert (count == 0 );
71
74
}
72
75
73
76
{
74
- auto f = for_each_test (0 );
75
- Iter it = std::for_each_n (Iter (ia), s, std::ref (f));
76
-
77
+ unsigned count = 0 ;
78
+ Iter it = std::for_each_n (Iter (ia), s, [&count](int & i) mutable {
79
+ ++i;
80
+ ++count;
81
+ });
77
82
assert (it == Iter (ia + s));
78
- assert (f. count == s);
83
+ assert (count == s);
79
84
for (unsigned i = 0 ; i < s; ++i)
80
85
assert (ia[i] == static_cast <int >(i + 1 ));
81
86
}
82
87
83
88
{
84
- auto f = for_each_test (0 );
85
- Iter it = std::for_each_n (Iter (ia), 1 , std::ref (f));
86
-
89
+ unsigned count = 0 ;
90
+ Iter it = std::for_each_n (Iter (ia), 1 , [&count](int & i) mutable {
91
+ ++i;
92
+ ++count;
93
+ });
87
94
assert (it == Iter (ia + 1 ));
88
- assert (f. count == 1 );
95
+ assert (count == 1 );
89
96
for (unsigned i = 0 ; i < 1 ; ++i)
90
97
assert (ia[i] == static_cast <int >(i + 2 ));
91
98
}
92
99
}
93
100
94
- #if TEST_STD_VER > 11
95
101
{
96
102
int ia[] = {1 , 3 , 6 , 7 };
97
103
int expected[] = {3 , 5 , 8 , 9 };
@@ -100,7 +106,6 @@ TEST_CONSTEXPR_CXX20 bool test() {
100
106
auto it = std::for_each_n (std::begin (ia), N, [](int & a) { a += 2 ; });
101
107
assert (it == (std::begin (ia) + N) && std::equal (std::begin (ia), std::end (ia), std::begin (expected)));
102
108
}
103
- #endif
104
109
105
110
if (!TEST_IS_CONSTANT_EVALUATED) // TODO: Use TEST_STD_AT_LEAST_26_OR_RUNTIME_EVALUATED when std::deque is made constexpr
106
111
test_segmented_deque_iterator ();
0 commit comments