- 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>
ceil(const time_point<Clock, Duration>& tp);
}
分解能が低いtime_point
に変換する際に、天井関数 (正の無限大方向への丸め、切り上げ) による丸めを行う。
return time_point<Clock, ToDuration>{ceil<ToDuration>(tp.time_since_epoch())};
- ceil[link /reference/chrono/duration/ceil.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 = ceil<seconds>(mp);
std::cout << sp.time_since_epoch().count() << std::endl;
}
- ceil[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]
2
- C++17
- GCC, C++17 mode: 7.3
- Clang, C++17 mode: 3.8
- Visual C++: ??
名前 | 説明 |
---|---|
time_point_cast |
ゼロ方向への丸め |
floor |
負の無限大方向への丸め |
round |
偶数方向への丸め |