Skip to content

Commit 6392c4a

Browse files
Fix int-in-bool-context warning in any_of and none_of tests (#2123)
1 parent 79fb7e5 commit 6392c4a

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

test/parallel_api/algorithm/alg.nonmodifying/any_of.pass.cpp

+5-1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020

2121
#include "support/utils.h"
2222

23+
#include <type_traits>
24+
2325
/*
2426
TODO: consider implementing the following tests for a better code coverage
2527
- correctness
@@ -55,7 +57,9 @@ test(size_t bits)
5557
Sequence<T> in(n, [n, bits](size_t) { return T(2 * HashBits(n, bits - 1) ^ 1); });
5658

5759
// Even value, or false when T is bool.
58-
T spike(2 * HashBits(n, bits - 1));
60+
T spike = 0;
61+
if constexpr (!std::is_same_v<T, bool>)
62+
spike = 2 * HashBits(n, bits - 1);
5963
Sequence<T> inCopy(in);
6064

6165
invoke_on_all_policies<0>()(test_any_of<T>(), in.begin(), in.end(), is_equal_to<T>(spike), false);

test/parallel_api/algorithm/alg.nonmodifying/none_of.pass.cpp

+5-1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020

2121
#include "support/utils.h"
2222

23+
#include <type_traits>
24+
2325
/*
2426
TODO: consider implementing the following tests for a better code coverage
2527
- correctness
@@ -53,7 +55,9 @@ test(size_t bits)
5355
Sequence<T> in(n, [n, bits](size_t) { return T(2 * HashBits(n, bits - 1) ^ 1); });
5456

5557
// Even value, or false when T is bool.
56-
T spike(2 * HashBits(n, bits - 1));
58+
T spike = 0;
59+
if constexpr (!std::is_same_v<T, bool>)
60+
spike = 2 * HashBits(n, bits - 1);
5761

5862
invoke_on_all_policies<0>()(test_none_of<T>(), in.begin(), in.end(), is_equal_to<T>(spike), true);
5963
invoke_on_all_policies<1>()(test_none_of<T>(), in.cbegin(), in.cend(), is_equal_to<T>(spike), true);

0 commit comments

Comments
 (0)