From 466b3d03f5a2359a63a7faa4eb110a0f1fbeafcd Mon Sep 17 00:00:00 2001 From: Luke Dashjr Date: Mon, 7 Jan 2019 16:00:34 +0000 Subject: [PATCH] CAmountMap::operator! to check if empty --- src/asset.cpp | 8 ++++++++ src/asset.h | 1 + 2 files changed, 9 insertions(+) diff --git a/src/asset.cpp b/src/asset.cpp index 9831c7ea5c..70c5a91154 100644 --- a/src/asset.cpp +++ b/src/asset.cpp @@ -121,6 +121,14 @@ bool operator!=(const CAmountMap& a, const CAmountMap& b) return !(a == b); } +bool operator!(const CAmountMap& a) +{ + for (const auto& it : a) { + if (it.second) return false; + } + return true; +} + bool hasNegativeValue(const CAmountMap& amount) { for(std::map::const_iterator it = amount.begin(); it != amount.end(); ++it) { diff --git a/src/asset.h b/src/asset.h index 381df84c4f..483170df32 100644 --- a/src/asset.h +++ b/src/asset.h @@ -93,6 +93,7 @@ bool operator>(const CAmountMap& a, const CAmountMap& b); bool operator>=(const CAmountMap& a, const CAmountMap& b); bool operator==(const CAmountMap& a, const CAmountMap& b); bool operator!=(const CAmountMap& a, const CAmountMap& b); +bool operator!(const CAmountMap& a); // Check if all values are 0 inline bool MoneyRange(const CAmountMap& mapValue) { for(CAmountMap::const_iterator it = mapValue.begin(); it != mapValue.end(); it++) {