Boost logo

Boost Users :

Subject: [Boost-users] [posix_time] time_duration operator/() overload
From: Norbert Wenzel (n_wenzel_at_[hidden])
Date: 2010-03-05 02:36:41


Hello,

I use boost::posix_time a lot in my code and I really do appreciate the
library. But there's one thing I was recently missing when comparing
time_durations to each other.

double time_duration::operator/(time_duration);

 From my point of view this is a perfectly valid operation (as opposed
to operator*(time_duration)) that returns the proportion of the two
durations. I need that operation to compute statistics like "n% of the
time I did x" or similar.

What I'm currently doing is computing the proportions via

time_duration::total_*()

which works fine, but leads to some coding effort, since I'll have to
cast one result to a real number to avoid integer division and some
checks to prevent /0.

I assume I'm not the first to compare time_durations so I was wondering
if there was a reason operator/() is not overloaded for time_duration?
Or if there is generally a better way to compare two durations?

thanks,
Norbert


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net