10 #if __cplusplus < 201703L
13 #include <type_traits>
19 template<
class Rep,
class Period>
struct is_duration<
std::chrono::duration<Rep, Period>>
22 template<
class To,
class Rep,
class Period,
class = std::enable_if_t<is_duration<To>{}>>
23 constexpr To floor(
const duration<Rep, Period>& d) {
24 To t = std::chrono::duration_cast<To>(d);
25 if (t > d)
return t - To{1};
29 template<
class To,
class Clock,
class FromDuration,
class = std::enable_if_t<is_duration<To>{}>>
30 constexpr std::chrono::time_point<Clock, To>
31 floor(
const std::chrono::time_point<Clock, FromDuration>& tp) {
32 return std::chrono::time_point<Clock, To>{ std::chrono::floor<To>(tp.time_since_epoch()) };