From d01ba804818f17a9aa9b93667b881fadc56cb5a7 Mon Sep 17 00:00:00 2001 From: Casey Bodley Date: Tue, 8 May 2018 13:04:17 -0400 Subject: [PATCH] include: utime_t can convert from ceph::coarse_real_time instead of accepting ceph::real_time directly, the converting constructor takes a std::chrono::time_point, constrained to clocks that support timespec conversions. this currently just means ceph::real_time and ceph::coarse_real_time Signed-off-by: Casey Bodley (cherry picked from commit 61fb24883e812c11016acea0654f6aef7ddab1f7) --- src/include/utime.h | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/include/utime.h b/src/include/utime.h index 7f6c2460b779a..92783bb941768 100644 --- a/src/include/utime.h +++ b/src/include/utime.h @@ -71,10 +71,12 @@ public: tv.tv_sec = v.tv_sec; tv.tv_nsec = v.tv_nsec; } - explicit utime_t(const ceph::real_time& rt) { - ceph_timespec ts = real_clock::to_ceph_timespec(rt); - decode_timeval(&ts); - } + // conversion from ceph::real_time/coarse_real_time + template >* = nullptr> + explicit utime_t(const std::chrono::time_point& t) + : utime_t(Clock::to_timespec(t)) {} // forward to timespec ctor + utime_t(const struct timeval &v) { set_from_timeval(&v); } -- 2.39.5