std::chrono::duration::count
来自cppreference.com
该页由英文版wiki使用Google Translate机器翻译而来。
该翻译可能存在错误或用词不当。鼠标停留在文本上可以看到原版本。你可以帮助我们修正错误或改进翻译。参见说明请点击这里. |
constexpr rep count() const; |
||
返回这个时间的刻度数.
原文:
Returns the number of ticks for this duration.
目录 |
[编辑] 参数
(无)
[编辑] 返回值
这个时间的刻度数.
原文:
The number of ticks for this duration.
[编辑] 示例
#include <chrono> #include <iostream> int main() { std::chrono::milliseconds ms{3}; // 3 milliseconds // 6000 microseconds constructed from 3 milliseconds std::chrono::microseconds us = 2*ms; // 30Hz clock using fractional ticks std::chrono::duration<double, std::ratio<1, 30>> hz30(3.5); std::cout << "3 ms duration has " << ms.count() << " ticks\n" << "6000 us duration has " << us.count() << " ticks\n" << "3.5 30Hz duration has " << hz30.count() << " ticks\n"; }
输出:
3 ms duration has 3 ticks 6000 us duration has 6000 ticks 3.5 30Hz duration has 3.5 ticks
[编辑] 另请参阅
一个持续时间转换到另一个,具有不同的周期的时间间隔 原文: converts a duration to another, with a different tick interval (函数模板) |