TestArray: constexpr_sum using span

Problem:
- `constexpr_sum` is implemented using `Array` which means the
  function needs to be a function template so that the size can be
  deduced.

Solution:
- Change the `Array` function argument to a `Span` since `Span` now is
  `constexpr`.
This commit is contained in:
Lenny Maiorani 2020-10-20 20:26:19 -04:00 committed by Andreas Kling
parent 18a40587ea
commit 91ea6057d6
Notes: sideshowbarker 2024-07-19 01:49:27 +09:00

View File

@ -28,12 +28,10 @@
#include <AK/Array.h>
// FIXME: Use Span<const int> as soon as Span has all the constexpr stuff too.
template<size_t Size>
static constexpr int constexpr_sum(const Array<int, Size>& array)
static constexpr int constexpr_sum(const Span<const int> span)
{
int sum = 0;
for (auto value : array)
for (auto value : span)
sum += value;
return sum;