Boost logo

Boost :

From: Deane Yang (deane_yang_at_[hidden])
Date: 2003-11-06 18:17:15

Andy Little wrote:

>... but could someone explain exactly why
>>something like:
>>inferred_type add_units(units_type first, other_units_type second)
>>is useful?
> operators ..... ! :-)

Great! Could you elaborate by what you mean by this?

The only operator+ I ever want to see in a units library
is one that adds two quantities with the same units.
But that's just my personal quirk.

I want to know why it is useful to be able to add two
quantities with different units and have the operator+
do the unit conversion inside of it. I'm sure there's
an obvious answer that will make me feel very dumb.

I guess I'm just a very risk averse person and prefer the safety
of strong type-checking and explicit casting to
the convenience of an operator+ that allows two different units.

(I do agree that what you're trying to do is an interesting programming

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