Boost logo

Boost :

From: Jan Langer (jan_at_[hidden])
Date: 2004-01-09 05:33:43


J.F.K. wrote:
> the solution proposed by Matthias Schabel and Deane Yang:
> 1) no automatic conversion (Rationale - it is error prone)
> code like this:
> L_cm = l1_cm + l2_m*cm_;

i understood it differently:
there is no quantity with a unit of centimeters. there is only a
quantity of dimension length. now you can refer to a system/model, eg.
si. so if you say si::length your unit is implicitly meters. if you dont
want that you have to define another system of base units.
then your example will become (pseudocode):

using namespace si;
using namespace si::symbols;
length l1 (5 * cm);
length l2 (5); // meters
length L = l1 + l2;

it will do first initialize l1 with 5*0.01, and the rest is computed in
meters.

> another possible solution (preffered to me):
> 2) automatic conversion of units with the same dimension
> if, ond only if appropriate converter provided (it isolate us from
> external contexts)

and in most cases you need _lots_ of converters. if you just consider 6
prefixes, you will need 5! converters, good luck with maintance.

> I call all interested people to vote and express your opinions.

i liked andys approach for computing the prefixes at compile time. but a
complete system of probably expression templates to defer the
computation to the end (assignment) is imho too complex.

maybe it is also possible to do the prefix stuff in the value_type. i'll
think about that if i have time.

jan

-- 
jan langer ... jan_at_[hidden]
"pi ist genau drei"

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