|
Boost : |
From: Jan Langer (jan_at_[hidden])
Date: 2003-10-16 12:47:45
Brock Peabody wrote:
>>i think its really impossible, because you can't know what conversions
>>will be needed in a specific system. and if a user needs its own system
>>(like the gasoline thing beman mentioned), he needs to rewrite nearly
>>everything from scratch. the library can only provide some tools to
>>define dimensions and conversions and so on in a shorter way.
>
> Ys, and I think it would be fairly straightforward assuming SI as base and
> some sort of compile time rational to specify conversion. Straightforward
> for the user that is :)
>
> typedef rational<1,1> one;
>
> typedef measurement_system<rational<1000,1>,
> one,
> one,
> one,
> one,
> one,
> one,
> one>::type my_units;
>
>
> Where my_units would be the metric system except using kilograms instead of
> grams.
i think you confuse something here: quantities and units (maybe i am
confusing the name ;-))
basically we need something like a dimension or unit represented as a
type without any measuring stuff. in an abstract sense this should be
like points in an n-dimensional space. the coordinates of this space are
represented by some compile-time container of numbers (int or
compile-time rational number or whatever).
now you define the operators for this space:
addition between equal points
multiplication -> addition of coordinates (exponents)
then a special system must be set up. eg the standard physical system.
each unit (what is the real name of what i mean - length, mass, volume
...) is just typedefed to a point in the space.
and the last layer defines quantities consisting of two compiletime
values (actual value type and point in the exponent space) and a
runtime-value.
what you try is to bring in the quantity in a too early layer.
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