diff --git a/src/base/stats/units.hh b/src/base/stats/units.hh index b2dfefa19e..87e6025b69 100644 --- a/src/base/stats/units.hh +++ b/src/base/stats/units.hh @@ -272,38 +272,6 @@ class Count : public Base std::string getUnitString() const override { return Count::toString(); } }; -template -class Rate : public Base -{ - static_assert(std::is_base_of::value, - "Rate(T1,T2) must have T1 and T2 derived from" - "Stats::Units::Base"); - static_assert(std::is_base_of::value, - "Rate(T1,T2) must have T1 and T2 derived from" - "Stats::Units::Base"); - private: - Rate() {} - public: - Rate(Rate const&) = delete; - void operator=(Rate const&) = delete; - static Rate* - get() - { - static Rate instance; - return &instance; - } - static std::string - toString() - { - return csprintf("(%s/%s)", T1::toString(), T2::toString()); - } - std::string - getUnitString() const override - { - return Rate::toString(); - } -}; - class Ratio : public Base { private: @@ -342,6 +310,41 @@ class Unspecified : public Base } }; +template +class Rate : public Base +{ + static_assert(std::is_base_of::value, + "Rate(T1,T2) must have T1 and T2 derived from Stats::Units::Base"); + static_assert(std::is_base_of::value, + "Rate(T1,T2) must have T1 and T2 derived from Stats::Units::Base"); + static_assert(!std::is_same::value || + std::is_same::value || std::is_same::value, + "Rate(T1,T2) must have T1 and T2 of different types; " + "otherwise, it would be a Ratio"); + + private: + Rate() {} + public: + Rate(Rate const&) = delete; + void operator=(Rate const&) = delete; + static Rate* + get() + { + static Rate instance; + return &instance; + } + static std::string + toString() + { + return csprintf("(%s/%s)", T1::toString(), T2::toString()); + } + std::string + getUnitString() const override + { + return Rate::toString(); + } +}; + } // namespace Units } // namespace Stats