diff --git a/src/test/app/SetAuth_test.cpp b/src/test/app/SetAuth_test.cpp index 3dd8ab590a4..adb909314d3 100644 --- a/src/test/app/SetAuth_test.cpp +++ b/src/test/app/SetAuth_test.cpp @@ -38,8 +38,8 @@ struct SetAuth_test : public beast::unit_test::suite using namespace jtx; Json::Value jv; jv[jss::Account] = account.human(); - jv[jss::LimitAmount] = STAmount(Issue{to_currency(currency), dest}) - .getJson(JsonOptions::none); + jv[jss::LimitAmount] = + STAmount({to_currency(currency), dest}).getJson(JsonOptions::none); jv[jss::TransactionType] = jss::TrustSet; jv[jss::Flags] = tfSetfAuth; return jv; diff --git a/src/test/jtx/amount.h b/src/test/jtx/amount.h index 0b408f80164..70a0bf51f34 100644 --- a/src/test/jtx/amount.h +++ b/src/test/jtx/amount.h @@ -161,64 +161,8 @@ operator!=(PrettyAmount const& lhs, PrettyAmount const& rhs) return !operator==(lhs, rhs); } -template -static std::string -to_places(const T d, std::uint8_t places) -{ - assert(places <= std::numeric_limits::digits10); - - std::ostringstream oss; - oss << std::setprecision(places) << std::fixed << d; - - std::string out = oss.str(); - out.erase(out.find_last_not_of('0') + 1, std::string::npos); - if (out.back() == '.') - out.pop_back(); - - return out; -} - -inline std::ostream& -operator<<(std::ostream& os, PrettyAmount const& amount) -{ - if (amount.value().isIssue()) - { - auto const& stAmount = get(amount); - if (stAmount.native()) - { - // measure in hundredths - auto const c = dropsPerXRP.drops() / 100; - auto const n = stAmount.mantissa(); - if (n < c) - { - if (stAmount.negative()) - os << "-" << n << " drops"; - else - os << n << " drops"; - return os; - } - auto const d = double(n) / dropsPerXRP.drops(); - if (stAmount.negative()) - os << "-"; - - os << to_places(d, 6) << " XRP"; - } - else - { - os << stAmount.getText() << "/" - << to_string(stAmount.issue().currency) << "(" << amount.name() - << ")"; - } - } - else - { - auto const& mptAmount = get(amount); - os << mptAmount.getText() << "/" - << to_string(mptAmount.issue().getMptID()) << "(" << amount.name() - << ")"; - } - return os; -} +std::ostream& +operator<<(std::ostream& os, PrettyAmount const& amount); //------------------------------------------------------------------------------ @@ -422,11 +366,11 @@ operator<<(std::ostream& os, IOU const& iou); //------------------------------------------------------------------------------ -/** Converts to MPT Issue or STAmount. +/** Converts to MPT Issue or STMPTAmount. Examples: MPT Converts to the underlying Issue - MPT(10) Returns STAmount of 10 of + MPT(10) Returns STMPTAmount of 10 of the underlying MPT */ class MPT @@ -526,11 +470,6 @@ struct AnyAmount } }; -inline PrettyAmount::operator AnyAmount() const -{ - return AnyAmount{amount_}; -} - inline AnyAmount any_t::operator()(STAmount const& sta) const { diff --git a/src/test/jtx/impl/amount.cpp b/src/test/jtx/impl/amount.cpp index 1813233a0aa..752d68ef1fd 100644 --- a/src/test/jtx/impl/amount.cpp +++ b/src/test/jtx/impl/amount.cpp @@ -47,6 +47,70 @@ operator<<(std::ostream&& os, } #endif +PrettyAmount::operator AnyAmount() const +{ + return {amount_}; +} + +template +static std::string +to_places(const T d, std::uint8_t places) +{ + assert(places <= std::numeric_limits::digits10); + + std::ostringstream oss; + oss << std::setprecision(places) << std::fixed << d; + + std::string out = oss.str(); + out.erase(out.find_last_not_of('0') + 1, std::string::npos); + if (out.back() == '.') + out.pop_back(); + + return out; +} + +std::ostream& +operator<<(std::ostream& os, PrettyAmount const& amount) +{ + if (amount.value().isIssue()) + { + auto const& stAmount = get(amount); + if (stAmount.native()) + { + // measure in hundredths + auto const c = dropsPerXRP.drops() / 100; + auto const n = stAmount.mantissa(); + if (n < c) + { + if (stAmount.negative()) + os << "-" << n << " drops"; + else + os << n << " drops"; + return os; + } + auto const d = double(n) / dropsPerXRP.drops(); + if (stAmount.negative()) + os << "-"; + + os << to_places(d, 6) << " XRP"; + } + else + { + os << stAmount.getText() << "/" + << to_string(stAmount.issue().currency) << "(" << amount.name() + << ")"; + } + } + else + { + auto const& mptAmount = get(amount); + os << mptAmount.getText() << "/" + << to_string(mptAmount.issue().getMptID()) << "(" << amount.name() + << ")"; + } + return os; +} + //------------------------------------------------------------------------------ XRP_t const XRP{}; diff --git a/src/test/jtx/impl/offer.cpp b/src/test/jtx/impl/offer.cpp index ef702c88b25..d6e2d89bc21 100644 --- a/src/test/jtx/impl/offer.cpp +++ b/src/test/jtx/impl/offer.cpp @@ -24,12 +24,11 @@ namespace ripple { namespace test { namespace jtx { -template -static Json::Value +Json::Value offer( Account const& account, - T const& takerPays, - STAmount const& takerGets, + STEitherAmount const& takerPays, + STEitherAmount const& takerGets, std::uint32_t flags) { Json::Value jv; @@ -42,26 +41,6 @@ offer( return jv; } -Json::Value -offer( - Account const& account, - STAmount const& takerPays, - STAmount const& takerGets, - std::uint32_t flags) -{ - return offer(account, takerPays, takerGets, flags); -} - -Json::Value -offer( - Account const& account, - STMPTAmount const& takerPays, - STAmount const& takerGets, - std::uint32_t flags) -{ - return offer(account, takerPays, takerGets, flags); -} - Json::Value offer_cancel(Account const& account, std::uint32_t offerSeq) { diff --git a/src/test/jtx/impl/trust.cpp b/src/test/jtx/impl/trust.cpp index f72ede5abe3..94f9d49ed46 100644 --- a/src/test/jtx/impl/trust.cpp +++ b/src/test/jtx/impl/trust.cpp @@ -63,11 +63,10 @@ trust( return jv; } -template Json::Value -claw_amount( +claw( Account const& account, - T const& amount, + STEitherAmount const& amount, std::optional const& mptHolder) { Json::Value jv; @@ -81,24 +80,6 @@ claw_amount( return jv; } -Json::Value -claw( - Account const& account, - STAmount const& amount, - std::optional const& mptHolder) -{ - return claw_amount(account, amount, mptHolder); -} - -Json::Value -claw( - Account const& account, - STMPTAmount const& amount, - std::optional const& mptHolder) -{ - return claw_amount(account, amount, mptHolder); -} - } // namespace jtx } // namespace test } // namespace ripple diff --git a/src/test/jtx/offer.h b/src/test/jtx/offer.h index 32db98a937a..2d66b24436e 100644 --- a/src/test/jtx/offer.h +++ b/src/test/jtx/offer.h @@ -32,15 +32,8 @@ namespace jtx { Json::Value offer( Account const& account, - STAmount const& takerPays, - STAmount const& takerGets, - std::uint32_t flags = 0); - -Json::Value -offer( - Account const& account, - STMPTAmount const& takerPays, - STAmount const& takerGets, + STEitherAmount const& takerPays, + STEitherAmount const& takerGets, std::uint32_t flags = 0); /** Cancel an offer. */ diff --git a/src/test/jtx/trust.h b/src/test/jtx/trust.h index e2f4bd475a8..03e045591ce 100644 --- a/src/test/jtx/trust.h +++ b/src/test/jtx/trust.h @@ -43,12 +43,7 @@ trust( Json::Value claw( Account const& account, - STAmount const& amount, - std::optional const& mptHolder = std::nullopt); -Json::Value -claw( - Account const& account, - STMPTAmount const& amount, + STEitherAmount const& amount, std::optional const& mptHolder = std::nullopt); } // namespace jtx diff --git a/src/test/ledger/BookDirs_test.cpp b/src/test/ledger/BookDirs_test.cpp index c023407c70a..b50f4381f48 100644 --- a/src/test/ledger/BookDirs_test.cpp +++ b/src/test/ledger/BookDirs_test.cpp @@ -82,10 +82,8 @@ struct BookDirs_test : public beast::unit_test::suite auto i = 1, j = 3, k = 0; for (auto const& e : d) { - BEAST_EXPECT( - get(e->getFieldAmount(sfTakerPays)) == AUD(i)); - BEAST_EXPECT( - get(e->getFieldAmount(sfTakerGets)) == XRP(j)); + BEAST_EXPECT(e->getFieldAmount(sfTakerPays) == AUD(i)); + BEAST_EXPECT(e->getFieldAmount(sfTakerGets) == XRP(j)); if (++k % 80 == 0) { ++i; diff --git a/src/test/ledger/Directory_test.cpp b/src/test/ledger/Directory_test.cpp index 7991e257f37..1a14feff061 100644 --- a/src/test/ledger/Directory_test.cpp +++ b/src/test/ledger/Directory_test.cpp @@ -136,12 +136,8 @@ struct Directory_test : public beast::unit_test::suite for (auto const& offer : book) { count++; - BEAST_EXPECT( - get(offer->getFieldAmount(sfTakerPays)) == - USD(count)); - BEAST_EXPECT( - get(offer->getFieldAmount(sfTakerGets)) == - XRP(count)); + BEAST_EXPECT(offer->getFieldAmount(sfTakerPays) == USD(count)); + BEAST_EXPECT(offer->getFieldAmount(sfTakerGets) == XRP(count)); } } diff --git a/src/test/protocol/Quality_test.cpp b/src/test/protocol/Quality_test.cpp index 64cf0c71b3a..741a341d980 100644 --- a/src/test/protocol/Quality_test.cpp +++ b/src/test/protocol/Quality_test.cpp @@ -29,7 +29,7 @@ class Quality_test : public beast::unit_test::suite // Create a raw, non-integral amount from mantissa and exponent STAmount static raw(std::uint64_t mantissa, int exponent) { - return STAmount(Issue{Currency(3), AccountID(3)}, mantissa, exponent); + return STAmount({Currency(3), AccountID(3)}, mantissa, exponent); } template diff --git a/src/test/protocol/STAmount_test.cpp b/src/test/protocol/STAmount_test.cpp index 39c93f4aa1c..e48d0500ba6 100644 --- a/src/test/protocol/STAmount_test.cpp +++ b/src/test/protocol/STAmount_test.cpp @@ -625,8 +625,7 @@ class STAmount_test : public beast::unit_test::suite try { - auto const t = - static_cast(amountFromString(usd, "136500")); + auto const t = amountFromString(usd, "136500"); fail(to_string(t.xrp())); } catch (std::logic_error const&) diff --git a/src/test/protocol/STObject_test.cpp b/src/test/protocol/STObject_test.cpp index 5a1ed3397dc..b55c1959363 100644 --- a/src/test/protocol/STObject_test.cpp +++ b/src/test/protocol/STObject_test.cpp @@ -563,7 +563,7 @@ class STObject_test : public beast::unit_test::suite st[sfAmount] = STEitherAmount{}; st[sfAccount] = AccountID{}; st[sfDigest] = uint256{}; - [&](STAmount) {}(get(st[sfAmount])); + [&](STEitherAmount) {}(st[sfAmount]); [&](AccountID) {}(st[sfAccount]); [&](uint256) {}(st[sfDigest]); } diff --git a/src/xrpld/app/misc/FeeVoteImpl.cpp b/src/xrpld/app/misc/FeeVoteImpl.cpp index 58f62e95bdb..8a03f877351 100644 --- a/src/xrpld/app/misc/FeeVoteImpl.cpp +++ b/src/xrpld/app/misc/FeeVoteImpl.cpp @@ -277,9 +277,9 @@ FeeVoteImpl::doVoting( } // choose our positions - // TODO: Use structured binding once LLVM 16 is the minimum supported - // version. See also: https://github.com/llvm/llvm-project/issues/48582 - // https://github.com/llvm/llvm-project/commit/127bf44385424891eb04cff8e52d3f157fc2cb7c + // TODO: Use structured binding once LLVM issue + // https://github.com/llvm/llvm-project/issues/48582 + // is fixed. auto const baseFee = baseFeeVote.getVotes(); auto const baseReserve = baseReserveVote.getVotes(); auto const incReserve = incReserveVote.getVotes();