Boost logo

Boost :

From: Andy Little (andy_at_[hidden])
Date: 2003-10-25 04:49:39


"Jan Langer" <jan_at_[hidden]> wrote in message
news:bncbtf$kv4$1_at_sea.gmane.org...
> Hugo Duncan wrote:
> > if we have
> >
> > quantity<NumericType, Unit, Dimension>
> >
> > then we can have a trait to determine whether or not the Unit has any
> > sort of trnsform asociated with it. The Unit could then provide the
> > (possibly static) functions required to perform the transform.
>
> in general i think we should stick to the idea that everything is stored
> and calculated in the fundamental unit. it should be made easy to change
> the fundamental unit. then everyone who needs a different internal
> scale, must say beforehand that he wants to use such a system. something
> like:
>
> typedef units_system <si, light_years> my_system;
>
> quantity <double, my_system::length> l1 (12); // 12 light_years
>
> // something quite small
> quantity <double, my_system::length> l2 = 1 * meter;
>
> ------------------------------------
>
> if the other path is followed, i'm also strongly in favor of hugo's
> idea, because it allows to do more complicated conversions between
> units. it could for example solve the celsius/fahrenheit issue.
>
> but a problem might be to avoid unneccessary conversions. for example
> between two non-fundamental conversions like km to inches. both units
> know their conversion to meters. but i dont know if it might be an issue
> if it multpiles with 1000 and then divides by 0.0254.
>
> and what should be the return type of an addition of kilometers and
inches.

using your scheme I have absolutely no idea... :-)

 Try here for an answer:
http://www.servocomm.freeserve.co.uk/Cpp/physical_quantity/index.html

Andy Little


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