std::chrono::time_point<Clock,Duration>::min
来自cppreference.com
< cpp | chrono | time point
工具库
日期和时间工具
时间点 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
时长 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
时钟 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
当天时刻 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
日历 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
时区 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
chrono I/O |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
(C++20)
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
C 风格日期和时间 |
std::chrono::time_point
成员函数 | ||||
(C++20)(C++20)
|
||||
time_point::min
|
||||
非成员函数 | ||||
(C++17)
|
||||
(C++17)
|
||||
(C++17)
|
||||
辅助类 | ||||
(C++26)
|
static constexpr time_point min();
|
(C++20 前) | |
static constexpr time_point min() noexcept;
|
(C++20 起) | |
返回拥有最小可能时长的 time_point
,即 time_point(std::chrono::duration::min()) 。
参数
(无)
返回值
最小的可能的 time_point
示例
运行此代码
#include <iostream> #include <ratio> #include <chrono> constexpr auto steady_min = std::chrono::steady_clock::time_point::min(); int main() { auto last_frame = steady_min; std::chrono::duration<float, std::milli> game_time {0.0F}; for (std::size_t count = 0; count < 5; ++count) { auto current_frame = std::chrono::steady_clock::now(); // 若是首帧则初始化计时器: if (last_frame == steady_min) last_frame = current_frame; game_time += current_frame - last_frame; std::cout << "Drawing frame at " << game_time.count() << " ms\n"; // 在时间偏移 game_time 绘制帧…… } }
可能的输出:
Drawing frame at 0 ms Drawing frame at 0.17551 ms Drawing frame at 0.358325 ms Drawing frame at 0.545384 ms Drawing frame at 0.736717 ms