From 9d8d3fa864edb5b7edb3946fc26c4ec1c7210cec Mon Sep 17 00:00:00 2001 From: Bruno BELANYI Date: Mon, 23 Aug 2021 19:24:53 +0200 Subject: [PATCH] abacus: bignum: extract do_dump Useful when debugging. --- src/bignum/bignum.cc | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/bignum/bignum.cc b/src/bignum/bignum.cc index 0aa102f..2121cdc 100644 --- a/src/bignum/bignum.cc +++ b/src/bignum/bignum.cc @@ -30,6 +30,11 @@ void trim_leading_zeros(digits_type& num) { num.erase(it.base(), num.end()); } +std::ostream& do_dump(digits_type const& num, std::ostream& out) { + std::copy(num.rbegin(), num.rend(), std::ostream_iterator(out)); + return out; +} + // More optimised than full-on div_mod digits_type do_halve(digits_type num) { assert(num.size() != 0); @@ -229,10 +234,8 @@ std::ostream& BigNum::dump(std::ostream& out) const { if (is_negative()) { out << '-'; } - std::copy(digits_.rbegin(), digits_.rend(), - std::ostream_iterator(out)); - return out; + return do_dump(digits_, out); } std::istream& BigNum::read(std::istream& in) {