Skip to content

Commit

Permalink
fix: use any of for is_out_of_range_value_included
Browse files Browse the repository at this point in the history
  • Loading branch information
Yuuichi Asahi committed Oct 3, 2024
1 parent fdec8db commit cab7636
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
8 changes: 4 additions & 4 deletions common/src/KokkosFFT_utils.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,14 +75,14 @@ bool is_out_of_range_value_included(const ContainerType& values, IntType max) {
static_assert(std::is_same_v<value_type, IntType>,
"is_out_of_range_value_included: Container value type must "
"match IntType");
const auto vmax = std::max_element(values.begin(), values.end());
if constexpr (std::is_signed_v<value_type>) {
const auto vmin = std::min_element(values.begin(), values.end());
KOKKOSFFT_THROW_IF(
*vmin < 0,
std::any_of(values.begin(), values.end(),
[](value_type value) { return value < 0; }),
"is_out_of_range_value_included: values must be non-negative");
}
return *vmax >= max;
return std::any_of(values.begin(), values.end(),
[max](value_type value) { return value >= max; });
}

template <
Expand Down
4 changes: 4 additions & 0 deletions common/unit_test/Test_Utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -338,6 +338,8 @@ void test_is_out_of_range_value_included() {
v, static_cast<IntType>(2)));
EXPECT_TRUE(KokkosFFT::Impl::is_out_of_range_value_included(
v, static_cast<IntType>(3)));
EXPECT_TRUE(KokkosFFT::Impl::is_out_of_range_value_included(
v, static_cast<IntType>(4)));
EXPECT_FALSE(KokkosFFT::Impl::is_out_of_range_value_included(
v, static_cast<IntType>(5)));
EXPECT_FALSE(KokkosFFT::Impl::is_out_of_range_value_included(
Expand All @@ -347,6 +349,8 @@ void test_is_out_of_range_value_included() {
v2, static_cast<IntType>(2)));
EXPECT_TRUE(KokkosFFT::Impl::is_out_of_range_value_included(
v2, static_cast<IntType>(3)));
EXPECT_TRUE(KokkosFFT::Impl::is_out_of_range_value_included(
v2, static_cast<IntType>(4)));
EXPECT_FALSE(KokkosFFT::Impl::is_out_of_range_value_included(
v2, static_cast<IntType>(5)));
EXPECT_FALSE(KokkosFFT::Impl::is_out_of_range_value_included(
Expand Down

0 comments on commit cab7636

Please sign in to comment.