- chrono[meta header]
- std::chrono[meta namespace]
- function[meta id-type]
- cpp17[meta cpp]
namespace std::chrono {
template <class ToDuration, class Clock, class Duration>
constexpr time_point<Clock, ToDuration>
floor(const time_point<Clock, Duration>& tp);
}
分解能が低いtime_point
に変換する際に、床関数 (負の無限大方向への丸め、切り下げ) による丸めを行う。
return time_point<Clock, ToDuration>{floor<ToDuration>(tp.time_since_epoch())};
- floor[link /reference/chrono/duration/floor.md]
- tp.time_since_epoch()[link time_since_epoch.md]
#include <iostream>
#include <chrono>
using namespace std::chrono;
int main()
{
using MTimePoint = time_point<system_clock, milliseconds>;
using STimePoint = time_point<system_clock, seconds>;
MTimePoint mp{milliseconds(1500)};
STimePoint sp = floor<seconds>(mp);
std::cout << sp.time_since_epoch().count() << std::endl;
}
- floor[color ff0000]
- milliseconds[link /reference/chrono/milliseconds.md]
- seconds[link /reference/chrono/seconds.md]
- system_clock[link /reference/chrono/system_clock.md]
- sp.time_since_epoch()[link time_since_epoch.md]
- count()[link /reference/chrono/duration/count.md]
1
- C++17
- GCC, C++17 mode: 7.3
- Clang, C++17 mode: 3.8
- Visual C++: ??
名前 | 説明 |
---|---|
time_point_cast |
ゼロ方向への丸め |
ceil |
正の無限大方向への丸め |
round |
偶数方向への丸め |