Boost logo

Boost :

From: Eric Lemings (lemings_at_[hidden])
Date: 2006-08-21 12:58:15


 

> -----Original Message-----
> From: boost-bounces_at_[hidden]
> [mailto:boost-bounces_at_[hidden]] On Behalf Of Matthias Troyer
> Sent: Sunday, August 20, 2006 6:29 AM
> To: boost_at_[hidden]
> Subject: Re: [boost] Boost Units library preview
>
>
...
> Wait, if I multiply quantities (which have units) then also the
> result will have a unit. E.g. if I divide 10 meters by 2
> seconds then
> I get 5 m/s . I wouldn't call that anonymous since I know the
> unit: m/s

This brings up a good question. Say you have two objects:

meters m = 1;
feet f = 2;

What is the type (or unit) of the following expression?

m * f;

Is it feet? meters? Some other type? If there is a rule (in
dimensional analysis), please let me know.

Meantime, I define the resulting type as not as a unit at all but
as the dimension of the unit:

void f (length l) {
  ...
}
f (m * f);

This is not to say that the user can not specify the desired
units:

rods r = m * f;

This is possible since a quantity of a compatible dimension can
be implicitly converted back into a measure of the appropriate
unit (in theory at least).

Eric.


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