lundi 27 juillet 2015

Chrono - The difference between two points in time in milliseconds?

How can I get (using the std::chrono library) the difference between two points in time in milliseconds?

I could do that using this:

std::chrono::time_point<std::chrono::system_clock> now = std::chrono::system_clock::now();

std::chrono::time_point<std::chrono::system_clock> foo = now + std::chrono::milliseconds(100);

std::chrono::duration<float> difference = foo - now;

const int milliseconds = difference.count() * 1000;

How can I get this time in milliseconds, so I can use the duration as a unsigned int, and not a float and then multiply by 1000?

Aucun commentaire:

Enregistrer un commentaire