@@ -233,6 +233,121 @@ CONSTEXPR20 bool test_transform() {
233233 return true ;
234234}
235235
236+ CONSTEXPR20 bool test_meow_of_helper (const size_t length_before, const size_t length, const size_t length_after) {
237+ const size_t total_length = length_before + length + length_after;
238+
239+ vector<bool > zeros (total_length);
240+ vector<bool > ones (total_length);
241+ vector<bool > mix (total_length);
242+
243+ const auto first_0 = zeros.begin () + static_cast <ptrdiff_t >(length_before);
244+ const auto last_0 = zeros.end () - static_cast <ptrdiff_t >(length_after);
245+ const auto first_1 = ones.begin () + static_cast <ptrdiff_t >(length_before);
246+ const auto last_1 = ones.end () - static_cast <ptrdiff_t >(length_after);
247+ const auto first_m = mix.begin () + static_cast <ptrdiff_t >(length_before);
248+ const auto last_m = mix.end () - static_cast <ptrdiff_t >(length_after);
249+
250+ fill (zeros.begin (), first_0, true );
251+ fill (last_0, zeros.end (), true );
252+ fill (first_1, last_1, true );
253+ fill (mix.begin (), first_m, true );
254+ fill (first_m + static_cast <ptrdiff_t >(length / 2 ), last_m, true );
255+
256+ if (length == 0 ) {
257+ #if _HAS_CXX20
258+ assert (all_of (first_0, last_0, identity{}) == true );
259+ assert (all_of (first_1, last_1, identity{}) == true );
260+ assert (all_of (first_m, last_m, identity{}) == true );
261+
262+ assert (any_of (first_0, last_0, identity{}) == false );
263+ assert (any_of (first_1, last_1, identity{}) == false );
264+ assert (any_of (first_m, last_m, identity{}) == false );
265+
266+ assert (none_of (first_0, last_0, identity{}) == true );
267+ assert (none_of (first_1, last_1, identity{}) == true );
268+ assert (none_of (first_m, last_m, identity{}) == true );
269+ #endif // _HAS_CXX20
270+
271+ assert (all_of (first_0, last_0, logical_not<>{}) == true );
272+ assert (all_of (first_1, last_1, logical_not<>{}) == true );
273+ assert (all_of (first_m, last_m, logical_not<>{}) == true );
274+
275+ assert (any_of (first_0, last_0, logical_not<>{}) == false );
276+ assert (any_of (first_1, last_1, logical_not<>{}) == false );
277+ assert (any_of (first_m, last_m, logical_not<>{}) == false );
278+
279+ assert (none_of (first_0, last_0, logical_not<>{}) == true );
280+ assert (none_of (first_1, last_1, logical_not<>{}) == true );
281+ assert (none_of (first_m, last_m, logical_not<>{}) == true );
282+ } else {
283+ assert (length != 1 ); // [first_m, last_m) needs to contain both true and false
284+
285+ #if _HAS_CXX20
286+ assert (all_of (first_0, last_0, identity{}) == false );
287+ assert (all_of (first_1, last_1, identity{}) == true );
288+ assert (all_of (first_m, last_m, identity{}) == false );
289+
290+ assert (any_of (first_0, last_0, identity{}) == false );
291+ assert (any_of (first_1, last_1, identity{}) == true );
292+ assert (any_of (first_m, last_m, identity{}) == true );
293+
294+ assert (none_of (first_0, last_0, identity{}) == true );
295+ assert (none_of (first_1, last_1, identity{}) == false );
296+ assert (none_of (first_m, last_m, identity{}) == false );
297+ #endif // _HAS_CXX20
298+
299+ assert (all_of (first_0, last_0, logical_not<>{}) == true );
300+ assert (all_of (first_1, last_1, logical_not<>{}) == false );
301+ assert (all_of (first_m, last_m, logical_not<>{}) == false );
302+
303+ assert (any_of (first_0, last_0, logical_not<>{}) == true );
304+ assert (any_of (first_1, last_1, logical_not<>{}) == false );
305+ assert (any_of (first_m, last_m, logical_not<>{}) == true );
306+
307+ assert (none_of (first_0, last_0, logical_not<>{}) == false );
308+ assert (none_of (first_1, last_1, logical_not<>{}) == true );
309+ assert (none_of (first_m, last_m, logical_not<>{}) == false );
310+ }
311+
312+ return true ;
313+ }
314+
315+ CONSTEXPR20 bool test_meow_of () {
316+ { // Super empty range
317+ const vector<bool >::const_iterator it{}; // value-initialized, compares equal to itself
318+
319+ #if _HAS_CXX20
320+ assert (all_of (it, it, identity{}) == true );
321+ assert (any_of (it, it, identity{}) == false );
322+ assert (none_of (it, it, identity{}) == true );
323+ #endif // _HAS_CXX20
324+
325+ assert (all_of (it, it, logical_not<>{}) == true );
326+ assert (any_of (it, it, logical_not<>{}) == false );
327+ assert (none_of (it, it, logical_not<>{}) == true );
328+ }
329+
330+ // Empty range
331+ test_meow_of_helper (0 , 0 , 3 );
332+ test_meow_of_helper (3 , 0 , 3 );
333+
334+ // One block, ends within block
335+ test_meow_of_helper (0 , 10 , 3 );
336+ test_meow_of_helper (3 , 10 , 3 );
337+
338+ // One block, exactly
339+ test_meow_of_helper (0 , blockSize, 0 );
340+
341+ // Multiple blocks, spanning
342+ test_meow_of_helper (3 , blockSize - 2 , 3 );
343+ test_meow_of_helper (3 , blockSize + 2 , 3 );
344+
345+ // Many blocks, exactly
346+ test_meow_of_helper (blockSize, 4 * blockSize, blockSize);
347+
348+ return true ;
349+ }
350+
236351CONSTEXPR20 void test_fill_helper (const size_t length) {
237352 // No offset
238353 {
@@ -1590,6 +1705,7 @@ static_assert(test_fill());
15901705static_assert (test_find());
15911706static_assert (test_count());
15921707static_assert (test_transform());
1708+ static_assert (test_meow_of());
15931709
15941710#if defined(__clang__) || defined(__EDG__) // TRANSITION, VSO-2574489
15951711static_assert (test_copy_part_1());
@@ -1602,6 +1718,7 @@ int main() {
16021718 test_find ();
16031719 test_count ();
16041720 test_transform ();
1721+ test_meow_of ();
16051722 test_copy_part_1 ();
16061723 test_copy_part_2 ();
16071724
0 commit comments