fix certain issues with TimeMicros
This commit is contained in:
parent
93f2e638cc
commit
0bae94ad2c
2 changed files with 18 additions and 7 deletions
|
|
@ -55,7 +55,7 @@ struct TimeMicros {
|
|||
}
|
||||
|
||||
// operators
|
||||
inline TimeMicros& operator+(TimeMicros& other) {
|
||||
inline TimeMicros& operator+=(TimeMicros& other) {
|
||||
seconds+=other.seconds;
|
||||
micros+=other.micros;
|
||||
while (micros>=1000000) {
|
||||
|
|
@ -64,11 +64,11 @@ struct TimeMicros {
|
|||
}
|
||||
return *this;
|
||||
}
|
||||
inline TimeMicros& operator+(int other) {
|
||||
inline TimeMicros& operator+=(int other) {
|
||||
seconds+=other;
|
||||
return *this;
|
||||
}
|
||||
inline TimeMicros& operator-(TimeMicros& other) {
|
||||
inline TimeMicros& operator-=(TimeMicros& other) {
|
||||
seconds-=other.seconds;
|
||||
micros-=other.micros;
|
||||
while (micros<0) {
|
||||
|
|
@ -77,7 +77,7 @@ struct TimeMicros {
|
|||
}
|
||||
return *this;
|
||||
}
|
||||
inline TimeMicros& operator-(int other) {
|
||||
inline TimeMicros& operator-=(int other) {
|
||||
seconds-=other;
|
||||
return *this;
|
||||
}
|
||||
|
|
@ -124,4 +124,16 @@ struct TimeMicros {
|
|||
seconds(0), micros(0) {}
|
||||
};
|
||||
|
||||
inline TimeMicros operator+(TimeMicros& t1, TimeMicros t2) {
|
||||
TimeMicros result=t1;
|
||||
result+=t2;
|
||||
return result;
|
||||
}
|
||||
|
||||
inline TimeMicros operator-(TimeMicros& t1, TimeMicros t2) {
|
||||
TimeMicros result=t1;
|
||||
result-=t2;
|
||||
return result;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue