Boost logo

Boost :

From: Andy Little (andy_at_[hidden])
Date: 2005-02-01 18:15:41


"Phil Richards" <news_at_[hidden]> wrote in message
news:20050201182448.45525F53B_at_derisoft.derived-software.demon.co.uk...
> On 2005-01-31, Andy Little <andy_at_[hidden]> wrote:
>> 1)Unfortunately not every one has the luxury. Many incoherent units
>> exist in
>> many real world situations, where errors cost money and worse.
>
> Indeed. But, again, many people only need/want dimensional analysis.
> My/our project is one of them. We've only been doing it with a
> dimensional analysis setup for 3 years, so we've probably not found
> all the limits yet.
>
>> 2)Even within SI a quantity can be expressed in various units.
>
> But even then there is only one dimensionality. If all you are
> interested in is dimensionality, then everything is hunky dory.

But you never are(OTOH maybe you are changing the impl from debug (quantity)
to release((double) ) You are always interested in the value and the value
must
have units ( whether explicit and local or, remote and implied). I agree
however that you might use an external convention and maybe this is an
alternative to the very explicit units attached to a type used in the pqs
UI. I guess you could select some particular unit for each of your your
quantities making a set, and then apply some compiletime or possibly
runtime scaling scaling factors to convert to somebody elses set. ( OTOH
AFAICS the logical outcome is that you may end up with the system used in
pqs.)

> Really, it is that simple for many people. I accept that there are
> also probably many who want unit conversion and checking as well,
> but even they would probably like *something* rather than nothing.

Well if you dont want the range of units , simply select only the base
units you want:

namespace my{
        typedef pqs::force::N force;
        typedef pqs::mass::kg mass;
        typedef pqs::acceleration::m_div_s2 acceleration;
}

using my::force;
using my::mass;
using my::acceleration;

int main()
{
     force f = mass(1) * acceleration(1);
}

regards
Andy Little


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