#ifndef CEPH_ENCODING_H
#define CEPH_ENCODING_H
+#include <concepts>
#include <set>
#include <map>
#include <deque>
// 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<typename Clock, typename Duration,
- typename std::enable_if_t<converts_to_timespec_v<Clock>>* = nullptr>
+template<clock_with_timespec Clock, typename Duration>
void encode(const std::chrono::time_point<Clock, Duration>& t,
ceph::bufferlist &bl) {
auto ts = Clock::to_timespec(t);
encode(ns, bl);
}
-template<typename Clock, typename Duration,
- typename std::enable_if_t<converts_to_timespec_v<Clock>>* = nullptr>
+template<clock_with_timespec Clock, typename Duration>
void decode(std::chrono::time_point<Clock, Duration>& t,
bufferlist::const_iterator& p) {
uint32_t s;
t = Clock::from_timespec(ts);
}
-template<typename Rep, typename Period,
- typename std::enable_if_t<std::is_integral_v<Rep>>* = nullptr>
+template<std::integral Rep, typename Period>
void encode(const std::chrono::duration<Rep, Period>& d,
ceph::bufferlist &bl) {
using namespace std::chrono;
encode(ns, bl);
}
-template<typename Rep, typename Period,
- typename std::enable_if_t<std::is_integral_v<Rep>>* = nullptr>
+template<std::integral Rep, typename Period>
void decode(std::chrono::duration<Rep, Period>& d,
bufferlist::const_iterator& p) {
int32_t s;
// Provide encodings for chrono::time_point and duration that use
// the underlying representation so are guaranteed to round-trip.
-template <typename Rep, typename Period,
- typename std::enable_if_t<std::is_integral_v<Rep>>* = nullptr>
+template <std::integral Rep, typename Period>
void round_trip_encode(const std::chrono::duration<Rep, Period>& d,
ceph::bufferlist &bl) {
const Rep r = d.count();
encode(r, bl);
}
-template <typename Rep, typename Period,
- typename std::enable_if_t<std::is_integral_v<Rep>>* = nullptr>
+template <std::integral Rep, typename Period>
void round_trip_decode(std::chrono::duration<Rep, Period>& d,
bufferlist::const_iterator& p) {
Rep r;