平台特定的std :: chrono :: high_resolution_clock :: ofence :: num
platform-specific std::chrono::high_resolution_clock::period::num
我已经注意到我测试过的每个系统的std::chrono::high_resolution_clock::period::num = 1
。是否存在任何系统(嵌入式,桌面,移动设备或其他)的系统?(在这样的系统上,1秒钟在tick中无法表示。)
我知道的std::chrono::high_resolution_clock
的三个实现:Visual Studio,GCC和Clang(与LIBC 一起使用时)。
这三个都有纳秒精确(std::chrono::high_resolution_clock::period::num = 1
)。对于VS和LIBC ,high_resolution_clock
被键入steady_clock
。在GCC上,它具有类型为system_clock
。
规格中没有任何阻止std::chrono::high_resolution_clock::period::num != 1
的东西,您是正确的,在这样的系统上,1秒钟在" ticks"中无法表示。这进一步转化为:
seconds
不会隐式转换为high_resolution_clock::duration
。
要找到seconds
和high_resolution_clock::duration
都可以转换到的最高持续时间,您可以便便使用:
using CT = common_type_t<seconds, high_resolution_clock::duration>;
对于我所知道的所有实现,CT
是nanoseconds
的类型 - ALIAS。
相关文章:
- 使用 SendInput 或 mouse_event 不适用于 clock()?
- 为什么当"::"的行为不像运算符时被称为'scope resolution operator'?
- 为什么我们可以在 c++ 中使用 srand(clock())?
- 除了使用 clock() 函数之外,有没有更好的方法来以给定的频率生成/发布数据
- IBM AIX std::clock()?
- 为什么我会得到"Invalid use of :: (scope resolution operator)?"
- 为什么常量CLOCKS_PER_SEC不需要用 std:: 命名,但 <ctime> clock() 和 clock_t 可以呢?
- 当我使用 cin 时,我如何使用 clock() 测量时间
- 'clock()' 给出通常的时钟而不是 CPU 时钟
- 使用Clock()函数测量程序的运行时间
- 为什么我的sf :: clock在sfml中单独重置
- C++:Linux 中的计时(使用 clock())不同步(由于 OpenMP?)
- 如何在Linux上获得C 代码块的时钟刻度?clock()结果没有意义
- clock :: getElapSedTime()被调用时SFML 2.0崩溃
- 为什么在使用基于 clock() 的计时器宏时会得到负值
- C++ SDL Resolution
- clock() 函数始终返回 0
- 使用 clock() 函数调度任务时出现问题
- RawInput resolution
- C++ VMWare Fusion/Boot Camp 下 VS2010 中 ctime 的 clock() 方法出现问题