8namespace smooth::feedback {
25concept Time =
requires(T t1, T t2,
double t_dbl)
28 {time_trait<T>::plus(t1, t_dbl)}->std::convertible_to<T>;
31 {time_trait<T>::minus(t2, t1)}->std::convertible_to<
double>;
39template<std::
floating_po
int T>
43 static constexpr T plus(T t,
double t_dbl) {
return t +
static_cast<T
>(t_dbl); }
45 static constexpr double minus(T t2, T t1) {
return static_cast<double>(t2 - t1); }
52template<
typename Clock,
typename Duration>
53struct time_trait<std::chrono::time_point<Clock, Duration>>
56 using T = std::chrono::time_point<Clock, Duration>;
58 static constexpr T plus(T t,
double t_dbl)
60 return t + std::chrono::duration_cast<Duration>(std::chrono::duration<double>(t_dbl));
63 static constexpr double minus(T t2, T t1)
65 return std::chrono::duration_cast<std::chrono::duration<double>>(t2 - t1).count();
73template<
typename Rep,
typename Ratio>
77 using T = std::chrono::duration<Rep, Ratio>;
79 static constexpr T plus(T t,
double t_dbl)
81 return t + std::chrono::duration_cast<T>(std::chrono::duration<double>(t_dbl));
84 static constexpr double minus(T t2, T t1)
86 return std::chrono::duration_cast<std::chrono::duration<double>>(t2 - t1).count();
A Time type supports right-addition with a double, and subtraction of two time types should be conver...
Trait class to specify Time operations.