Boost logo

Boost :

From: Beth Jacobson (bethj_at_[hidden])
Date: 2006-05-05 13:32:14


Time durations can be divided by an integer to produce a duration (e.g.
hours(1)/60 == minutes(1);), but can't be divided by another duration to
produce an integer (e.g. hours(1)/minutes(1) == 60;).

Could this be added to time_duration.hpp:

int operator/(const duration_type& d) const
{
   return (ticks_ / d.ticks_);
}

or maybe better, this:

double operator/(const duration_type& d) const
{
   return (static_cast<double>(ticks_) / d.ticks_);
}

The same thing can already be accomplished already with
duration1.ticks()/duration2.ticks(), but duration1/duration2 seems more
natural and fits well with the rest of the date_time operators.

Beth


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk