1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
|
// duration::count
#include <iostream> // std::cout
#include <chrono> // std::chrono::seconds, std::chrono::milliseconds
// std::chrono::duration_cast
int main ()
{
using namespace std::chrono;
// std::chrono::milliseconds is an instatiation of std::chrono::duration:
milliseconds foo (1000); // 1 second
foo*=60;
std::cout << "duration (in periods): ";
std::cout << foo.count() << " milliseconds.\n";
std::cout << "duration (in seconds): ";
std::cout << foo.count() * milliseconds::period::num / milliseconds::period::den;
std::cout << " seconds.\n";
return 0;
}
| |