From the course: C++ Development: Advanced Concepts, Lambda Expressions, and Best Practices

Unlock the full course today

Join today to access over 24,900 courses taught by industry experts.

The chrono library

The chrono library

- [Instructor] The chrono library provides tools for measuring and reporting time and intervals. Most of these classes and functions were introduced with C++ 11. This is chrono.cpp from chapter seven of the exercise files. We're going to start down here in main because I want to talk to you about the different types of clocks that are available. Here, we're getting the current time, and we're printing it out in the print statement here. And you notice that we're using a clock called system_clock from the chrono library. And there's a function in system_clock called now, which gives us a time object, which we can then use in our formatter. And when I build and run this, you'll see that the time comes out right here at the top, and it says, "system_clock::now is," and that's the time that it gives. The system clock is the best clock for finding the current system time. It is not terribly useful for measuring intervals.…

Contents