A deep dive into C++ std::chrono covering its three building blocks: durations, time points, and clocks. Explains the three C++11 standard clocks (system_clock, steady_clock, high_resolution_clock) and the newer C++20 additions (UTC, TAI, GPS, file clocks). Covers clock conversions using clock_cast, duration casting pitfalls with floor/ceil/round, building custom clocks for testing and simulations, and time zone support introduced in C++20. Practical guidance includes using steady_clock for elapsed time measurement, injecting time as a dependency for testability, and avoiding high_resolution_clock unless platform-verified.

59m watch time
1 Impression