diff --git a/src/common/ceph_time.h b/src/common/ceph_time.h index 6ada4d8944c..bae038862cf 100644 --- a/src/common/ceph_time.h +++ b/src/common/ceph_time.h @@ -529,6 +529,9 @@ struct converts_to_timespec constexpr bool converts_to_timespec_v = converts_to_timespec::value; +template +concept clock_with_timespec = converts_to_timespec_v; + template static Rep to_seconds(T t) { return std::chrono::duration_cast< diff --git a/src/include/encoding.h b/src/include/encoding.h index aac63a7e6cc..08c67c33eec 100644 --- a/src/include/encoding.h +++ b/src/include/encoding.h @@ -14,6 +14,7 @@ #ifndef CEPH_ENCODING_H #define CEPH_ENCODING_H +#include #include #include #include @@ -326,8 +327,7 @@ inline void decode_nohead(int len, bufferlist& s, bufferlist::const_iterator& p) // for time_point and duration are backward-compatible with utime_t, but // truncate seconds to 32 bits so are not guaranteed to round-trip. -template>* = nullptr> +template void encode(const std::chrono::time_point& t, ceph::bufferlist &bl) { auto ts = Clock::to_timespec(t); @@ -338,8 +338,7 @@ void encode(const std::chrono::time_point& t, encode(ns, bl); } -template>* = nullptr> +template void decode(std::chrono::time_point& t, bufferlist::const_iterator& p) { uint32_t s; @@ -353,8 +352,7 @@ void decode(std::chrono::time_point& t, t = Clock::from_timespec(ts); } -template>* = nullptr> +template void encode(const std::chrono::duration& d, ceph::bufferlist &bl) { using namespace std::chrono; @@ -364,8 +362,7 @@ void encode(const std::chrono::duration& d, encode(ns, bl); } -template>* = nullptr> +template void decode(std::chrono::duration& d, bufferlist::const_iterator& p) { int32_t s; @@ -378,16 +375,14 @@ void decode(std::chrono::duration& d, // Provide encodings for chrono::time_point and duration that use // the underlying representation so are guaranteed to round-trip. -template >* = nullptr> +template void round_trip_encode(const std::chrono::duration& d, ceph::bufferlist &bl) { const Rep r = d.count(); encode(r, bl); } -template >* = nullptr> +template void round_trip_decode(std::chrono::duration& d, bufferlist::const_iterator& p) { Rep r;