c++boostboost-format

How to cumulate time durations


I am using boost::format variable to get elapsed time in seconds

boost::posix_time::time_duration  total_time = start_1.elapsed();
long milliseconds = total_time.total_milliseconds();
boost::format output("%.6f");
output % (milliseconds/1000.0);

But I use the timer several times to cumulate durations. I want to know with which type of variable can I cumulate durations ( use the operator +). For example with a float by I don't know how to convert from boost::format to float

Thanks in advance


Solution

  • According to the documentation documentation, time_duration has operator +. So it is possible to use time_duration itself to accumulate durations.