Skip to content

Commit 2e9841b

Browse files
committed
system_clock::duration and steady_clock::duration can be different types
1 parent b8c9c6e commit 2e9841b

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/datadog/clock.h

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,15 @@ inline Duration operator-(const TimePoint& after, const TimePoint& before) {
3939
}
4040

4141
inline TimePoint operator-(const TimePoint& origin, Duration offset) {
42-
return {origin.wall - offset, origin.tick - offset};
42+
return {origin.wall -
43+
std::chrono::duration_cast<std::chrono::system_clock::duration>(
44+
offset),
45+
origin.tick - offset};
4346
}
4447

4548
inline TimePoint& operator+=(TimePoint& self, Duration offset) {
46-
self.wall += offset;
49+
self.wall +=
50+
std::chrono::duration_cast<std::chrono::system_clock::duration>(offset);
4751
self.tick += offset;
4852
return self;
4953
}

0 commit comments

Comments
 (0)