Boost logo

Boost :

From: Beth Jacobson (bethj_at_[hidden])
Date: 2006-05-06 15:34:27

Jeff Garland wrote:
> Beth Jacobson wrote:
>> 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_);
>> }
> Reasonable -- of course it will have the usual integer division issues.
>> 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.
> Well, I've managed to avoid injecting any "fuzzy floating point logic"
> into date_time up till now. I guess I'd like to hear a compelling use
> case from you or others as to why this is really needed.

Given your arguments, I'm afraid I can't come up with one. In the field
I'm working in (crop modeling), dividing durations is a vital function,
but I can't think of a compelling reason for it to be a member function.

Thanks for your time and attention on this, and thank you for the
date_time library. It fits the modeling paradigm beautifully, and it's a
pleasure to use.


Boost list run by bdawes at, gregod at, cpdaniel at, john at