在线文档教程
C++
应用 | Utilities

std::chrono::duration::count

STD::时间::持续时间:计数

constexpr rep count() const;

返回此期间的蜱数。

参数

%280%29

返回值

此期间的蜱数。

二次

#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

二次

另见

duration_castconverts a duration to another, with a different tick interval (function template)

© cppreference.com

在CreativeCommonsAttribution下授权-ShareAlike未移植许可v3.0。

http://en.cppreference.com/w/cpp/rono/工期/count