dimanche 28 février 2016

std::chrono::system_clock and duration

I can measure time using:

t1 = system_clock::now();
...
t2 = system_clock::now();

duration<double> d = t2 - t1;

That compiles fine, but how do I do the reverse? I want to move a time point using duration?

example (does not compile):

system_clock::time_point tp1 = system_clock::now();
system_clock::time_point tp2 = tp1 + duration<double>(1.0);

The system_clock::time_point '+' operator does not seem to accept duration<double>.

How can I move a time point by a duration specified using time in seconds (floating point value)? I need to use system_clock because it can convert to time_t.

Aucun commentaire:

Enregistrer un commentaire