From a152a64f1cdba50ca3708bdc077a0767cd75e99c Mon Sep 17 00:00:00 2001 From: Michael Davidsaver Date: Wed, 30 Aug 2017 17:04:02 -0500 Subject: [PATCH] RefSnapshot operator move into class definition to hopefully appease MSVC --- src/misc/pv/reftrack.h | 15 ++++++--------- src/misc/reftrack.cpp | 8 ++++---- 2 files changed, 10 insertions(+), 13 deletions(-) diff --git a/src/misc/pv/reftrack.h b/src/misc/pv/reftrack.h index 30a07f4..8f694bc 100644 --- a/src/misc/pv/reftrack.h +++ b/src/misc/pv/reftrack.h @@ -95,17 +95,14 @@ public: counts.swap(o.counts); } - friend RefSnapshot operator-(const RefSnapshot& lhs, const RefSnapshot& rhs); + /** Compute the difference lhs - rhs + * + * Returned RefSnapshot has Count::current=lhs.current + * and Count::delta= lhs.current - rhs.current + */ + RefSnapshot operator-(const RefSnapshot& rhs) const; }; -/** Compute the difference lhs - rhs - * - * Returned RefSnapshot has Count::current=lhs.current - * and Count::delta= lhs.current - rhs.current - */ -epicsShareFunc -RefSnapshot operator-(const RefSnapshot& lhs, const RefSnapshot& rhs); - //! Print all counters with a non-zero delta epicsShareFunc std::ostream& operator<<(std::ostream& strm, const RefSnapshot& snap); diff --git a/src/misc/reftrack.cpp b/src/misc/reftrack.cpp index 00bd02b..b83b9a0 100644 --- a/src/misc/reftrack.cpp +++ b/src/misc/reftrack.cpp @@ -121,12 +121,12 @@ void RefSnapshot::update() } } -RefSnapshot operator-(const RefSnapshot& lhs, const RefSnapshot& rhs) +RefSnapshot RefSnapshot::operator-(const RefSnapshot& rhs) const { RefSnapshot ret; - RefSnapshot::cnt_map_t::const_iterator lit = lhs.counts.begin(), - lend= lhs.counts.end(), + RefSnapshot::cnt_map_t::const_iterator lit = counts.begin(), + lend= counts.end(), rit = rhs.counts.begin(), rend= rhs.counts.end(); @@ -137,7 +137,7 @@ RefSnapshot operator-(const RefSnapshot& lhs, const RefSnapshot& rhs) ++rit; } else if(rit==rend || lit->first < rit->first) { - ret.counts[lit->first] = RefSnapshot::Count(lit->second.current, lit->second.current); + ret.counts[lit->first] = RefSnapshot::Count(lit->second.current, long(lit->second.current)); ++lit; } else { // !end and lit->first == rit->first