diff --git a/CMakeLists.txt b/CMakeLists.txt index 7d72bf3..d343e5a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -4,7 +4,7 @@ enable_testing() add_library(common_options INTERFACE) target_compile_features(common_options INTERFACE - cxx_std_20 + cxx_std_17 ) target_compile_options(common_options INTERFACE -Wall diff --git a/src/bignum/bignum.cc b/src/bignum/bignum.cc index cadc170..2121cdc 100644 --- a/src/bignum/bignum.cc +++ b/src/bignum/bignum.cc @@ -3,7 +3,6 @@ #include #include #include -#include #include #include @@ -83,17 +82,18 @@ digits_type do_addition(digits_type const& lhs, digits_type const& rhs) { ++it2; } - auto leftover = [=]() { - if (it1 != end1) { - return std::span(it1, end1); - } - return std::span(it2, end2); - }(); + auto it = it1; + auto end = end1; + if (it1 == end1) { + it = it2; + end = end2; + } - for (auto value : leftover) { - int addition = value + carry; + while (it != end) { + int addition = *it + carry; carry = addition / BASE; res.push_back(addition % BASE); + ++it; } if (carry != 0) {