From bfa8db613903fd50ce45c037b0d8ad505e85682f Mon Sep 17 00:00:00 2001 From: Chip Hogg Date: Fri, 11 Mar 2022 03:48:57 +0000 Subject: [PATCH] Use std::accumulate --- src/core/include/units/bits/prime.h | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/core/include/units/bits/prime.h b/src/core/include/units/bits/prime.h index 4baed1c4..47eb2dbe 100644 --- a/src/core/include/units/bits/prime.h +++ b/src/core/include/units/bits/prime.h @@ -25,6 +25,7 @@ #include #include #include +#include #include #include @@ -88,9 +89,7 @@ constexpr auto coprimes_up_to(std::size_t n, const std::array &b template constexpr std::size_t product(const std::array &values) { - std::size_t product = 1; - for (const auto &v : values) { product *= v; } - return product; + return std::accumulate(std::begin(values), std::end(values), std::size_t{1u}, std::multiplies{}); } // A configurable instantiation of the "wheel factorization" algorithm [1] for prime numbers.