定义于头文件
<chrono>
|
||
template <class ToDuration, class Clock, class Duration>
constexpr time_point<Clock, ToDuration> floor(const time_point<Clock, Duration>& tp); |
(C++17 起) | |
返回能以 ToDuration
表示的小于或等于 tp
的最大时间点 t
。
函数不参与重载决议,除非 ToDuration
是 std::chrono::duration 的特化。
目录 |
tp | - | 要向下舍入的 time_point |
向下舍入到使用 ToDuration
类型时长的下一个时间点的 tp
。
template <class T> struct is_duration : std::false_type {}; template <class Rep, class Period> struct is_duration< std::chrono::duration<Rep, Period>> : std::true_type {}; template <class To, class Clock, class FromDuration, class = std::enable_if_t<is_duration<To>{}>> constexpr std::chrono::time_point<Clock, To> floor(const std::chrono::time_point<Clock, FromDuration>& tp) { return std::chrono::time_point<Clock, To>{ std::chrono::floor<To>(tp.time_since_epoch())}; } |
本节未完成 原因:暂无示例 |
转换 time_point 为同一时钟上拥有不同 duration 的另一 time_point (函数模板) |
|
(C++17)
|
转换 time_point 到另一个,向上取整 (函数模板) |
(C++17)
|
转换 time_point 到另一个,取整至最接近者,偶数优先 (函数模板) |
(C++17)
|
以向下取整的方式,将一个时间间隔转换为另一个 (函数模板) |
不大于给定值的最接近整数 (函数) |