std::chrono...tion::count(3)
π std::chrono::duration::count π
β¨ NAME β¨
std::chrono::duration::count - std::chrono::duration::count
okay so bestie, this page is from the C++ Standard Libary β yes, that spelling, not mine π β and the NAME is literally the same thing twice. we love a repetitive icon π β¨
β¨ Synopsis β¨
constexpr rep count() const;
(since C++11) πΈ
Returns the number of ticks for this duration. that's the whole vibe π«Ά
β¨ Parameters β¨
(none) β zero parameters, no cap. she takes nothing and still serves π
β¨ Return value β¨
The number of ticks for this duration. periodt π
β¨ Example β¨
okay so here's the exact example, copied with love and zero edits β yes, even that one line wrap, don't come for me π:
// Run this code
#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";
}
β¨ Output β¨
and the output is giving exactly this β¨:
3 ms duration has 3 ticks
6000 us duration has 6000 ticks
3.5 30Hz duration has 3.5 ticks
β¨ See also β¨
duration_castβ converts a duration to another, with a different tick interval β(C++11)(function template)π
source/version: http://cppreference.com β date: 2024.06.10 β okay bye bestie, that's the whole page, mwah π«Άπβ¨
π¦ where this page comes from
- nixpkgs unstable: stdman 2024.07.05
- opensuse-leap 16.0: stdman 2024.07.05-bp160.1.9 Β· MIT
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms