Skip to content

Commit

Permalink
TestArray: constexpr_sum using span
Browse files Browse the repository at this point in the history
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`.
  • Loading branch information
ldm5180 authored and awesomekling committed Oct 21, 2020
1 parent 18a4058 commit 91ea605
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions AK/Tests/TestArray.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 91ea605

Please sign in to comment.