Index: base/time/time.h |
diff --git a/base/time/time.h b/base/time/time.h |
index 6d618614aef3ed7574f3f279c37805356d935067..efcfa3e7fb73f31d52021a819d7ac39a9a86528a 100644 |
--- a/base/time/time.h |
+++ b/base/time/time.h |
@@ -158,34 +158,31 @@ class BASE_EXPORT TimeDelta { |
return TimeDelta(-delta_); |
} |
- // Computations with ints, note that we only allow multiplicative operations |
- // with ints, and additive operations with other deltas. |
- TimeDelta operator*(int64 a) const { |
+ // Computations with numeric types, note that we only allow multiplicative |
+ // operations with other types. |
rvargas (doing something else)
2015/02/21 01:17:45
nit: Thanks. The comment was certainly confusing.
michaeln
2015/02/23 20:02:17
Done
|
+ template<typename T> |
+ TimeDelta operator*(T a) const { |
return TimeDelta(delta_ * a); |
} |
- TimeDelta operator/(int64 a) const { |
+ template<typename T> |
+ TimeDelta operator/(T a) const { |
return TimeDelta(delta_ / a); |
} |
- TimeDelta& operator*=(int64 a) { |
+ template<typename T> |
+ TimeDelta& operator*=(T a) { |
delta_ *= a; |
return *this; |
} |
- TimeDelta& operator/=(int64 a) { |
+ template<typename T> |
+ TimeDelta& operator/=(T a) { |
delta_ /= a; |
return *this; |
} |
+ |
int64 operator/(TimeDelta a) const { |
return delta_ / a.delta_; |
} |
- // Multiplicative computations with floats. |
- TimeDelta multiply_by(double a) const { |
- return TimeDelta(delta_ * a); |
- } |
- TimeDelta divide_by(double a) const { |
- return TimeDelta(delta_ / a); |
- } |
- |
// Defined below because it depends on the definition of the other classes. |
Time operator+(Time t) const; |
TimeTicks operator+(TimeTicks t) const; |
@@ -213,7 +210,8 @@ class BASE_EXPORT TimeDelta { |
private: |
friend class Time; |
friend class TimeTicks; |
- friend TimeDelta operator*(int64 a, TimeDelta td); |
+ template<typename T> |
rvargas (doing something else)
2015/02/21 01:17:44
We can remove this...
|
+ friend TimeDelta operator*(T a, TimeDelta td); |
// Constructs a delta given the duration in microseconds. This is private |
// to avoid confusion by callers with an integer constructor. Use |
@@ -225,7 +223,8 @@ class BASE_EXPORT TimeDelta { |
int64 delta_; |
}; |
-inline TimeDelta operator*(int64 a, TimeDelta td) { |
+template<typename T> |
+inline TimeDelta operator*(T a, TimeDelta td) { |
return TimeDelta(a * td.delta_); |
rvargas (doing something else)
2015/02/21 01:17:45
with a
return td * a;
michaeln
2015/02/23 20:02:18
Done (thnx)
|
} |