diff options
Diffstat (limited to 'cpp/include/IceUtil/Time.h')
-rw-r--r-- | cpp/include/IceUtil/Time.h | 33 |
1 files changed, 32 insertions, 1 deletions
diff --git a/cpp/include/IceUtil/Time.h b/cpp/include/IceUtil/Time.h index 776e6c56354..a2a49b09ee7 100644 --- a/cpp/include/IceUtil/Time.h +++ b/cpp/include/IceUtil/Time.h @@ -31,7 +31,6 @@ public: static Time microSeconds(Int64); operator timeval() const; - operator double() const; Int64 toSeconds() const; Int64 toMilliSeconds() const; @@ -96,6 +95,20 @@ public: return _usec != rhs._usec; } + template<typename T> + Time& operator*=(T rhs) + { + _usec *= rhs; + return *this; + } + + template<typename T> + Time& operator/=(T rhs) + { + _usec /= rhs; + return *this; + } + private: Time(Int64); @@ -103,6 +116,24 @@ private: Int64 _usec; }; +template<typename T> +Time operator*(const Time& lhs, T rhs) +{ + return Time::microSeconds(static_cast<Int64>(lhs.toMicroSeconds() * rhs)); +} + +template<typename T> +Time operator*(T rhs, const Time& lhs) +{ + return Time::microSeconds(static_cast<Int64>(lhs * rhs.toMicroSeconds())); +} + +template<typename T> +Time operator/(const Time& lhs, T rhs) +{ + return Time::microSeconds(static_cast<Int64>(lhs.toMicroSeconds() / rhs)); +} + } // End namespace IceUtil #endif |