1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 12:07:45 +00:00

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

View file

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