mirror of
https://github.com/mpusz/mp-units.git
synced 2025-08-06 13:44:27 +02:00
Use std::accumulate
This commit is contained in:
@@ -25,6 +25,7 @@
|
||||
#include <array>
|
||||
#include <cassert>
|
||||
#include <cstddef>
|
||||
#include <numeric>
|
||||
#include <optional>
|
||||
#include <tuple>
|
||||
|
||||
@@ -88,9 +89,7 @@ constexpr auto coprimes_up_to(std::size_t n, const std::array<std::size_t, N> &b
|
||||
|
||||
template<std::size_t N>
|
||||
constexpr std::size_t product(const std::array<std::size_t, N> &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.
|
||||
|
Reference in New Issue
Block a user