RefSnapshot operator

move into class definition to hopefully appease MSVC
This commit is contained in:
Michael Davidsaver
2017-08-30 17:04:02 -05:00
parent 08f50e56ac
commit a152a64f1c
2 changed files with 10 additions and 13 deletions

View File

@@ -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);

View File

@@ -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