From 8cb26ee31611287cc32d8cf042bac47198e5c5f0 Mon Sep 17 00:00:00 2001 From: Bruno BELANYI Date: Tue, 12 Oct 2021 15:05:21 +0200 Subject: [PATCH] abacus: bignum: use span Once again, the code looks cleaner that way. --- src/bignum/bignum.cc | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/bignum/bignum.cc b/src/bignum/bignum.cc index 6b6987e..cadc170 100644 --- a/src/bignum/bignum.cc +++ b/src/bignum/bignum.cc @@ -3,6 +3,7 @@ #include #include #include +#include #include #include @@ -82,18 +83,17 @@ digits_type do_addition(digits_type const& lhs, digits_type const& rhs) { ++it2; } - auto [it, end] = [=]() { + auto leftover = [=]() { if (it1 != end1) { - return std::make_pair(it1, end1); + return std::span(it1, end1); } - return std::make_pair(it2, end2); + return std::span(it2, end2); }(); - while (it != end) { - int addition = *it + carry; + for (auto value : leftover) { + int addition = value + carry; carry = addition / BASE; res.push_back(addition % BASE); - ++it; } if (carry != 0) {