- 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>
round(const time_point<Clock, Duration>& tp);
}
分解能が低いtime_point
に変換する際に、偶数方向への丸め (最近接偶数への丸め) を行う。
return time_point<Clock, ToDuration>{round<ToDuration>(tp.time_since_epoch())};
- ceil[link /reference/chrono/duration/ceil.md]
- tp.time_since_epoch()[link time_since_epoch.md]
treat_as_floating_point
<typename ToDuration::rep>::value == true
である場合、この関数はオーバーロード解決の候補から外れる
#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 = round<seconds>(mp);
std::cout << sp.time_since_epoch().count() << std::endl;
}
- round[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 |
負の無限大方向への丸め |
ceil |
正の無限大方向への丸め |