Skip to content

Instantly share code, notes, and snippets.

@deque-blog
Last active May 3, 2017 14:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save deque-blog/c937f9e6c29a24af5e156ea890b92a9c to your computer and use it in GitHub Desktop.
Save deque-blog/c937f9e6c29a24af5e156ea890b92a9c to your computer and use it in GitHub Desktop.
template<typename Number, size_t N>
constexpr Number average(std::array<Number, N> const& vals)
{
Number total = 0;
for (int i = 0; i < N; ++i)
total += vals[i];
return total / N;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment