Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
template<typename Number, size_t N>
constexpr Number average(std::array<Number, N> const& vals)
// Fails to compile as std::accumulate is not constexpr
return std::accumulate(vals.begin(), vals.end(), 0, std::plus<Number>{}) / N;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment