Boost logo

Boost :

From: Rene Jager (renej_at_[hidden])
Date: 2001-04-13 07:18:56


i'd like to throw in my 2 cents...

we use a template-based SI physical type (from some book, can look it up):

namespace si {
template <class T, int mass_index, int length_index, time_index, temp_index,
current_index,
    int lum_index, angle_index> // we left out steradian
class physical { typedef T value_type; ... };
// specialized physical<0,0,...,0> -> dimensionless, free convertable from/to
value_type
} // si

predefined: mass (kilogram), length (meter), time (second), thermodynamic
temperature (kelvin), electric current (ampere), luminous intensity (candela),
angle (meter/meter)
and a whole list of derived units (potential (volt), velocity (meter/second)
etc.)

typedef physical<0,1,0,..,0> length;
typedef physical<0,0,1,0,...,0> time;
typedef physical<0,1,-1,0,..,0> velocity;
velocity v = length(2)/time(2) // the division will result in a
physical<0,1,-1,0..,0>
v = time(1); // compiler error

using this is, all implementations of physics related stuff is checked by the
compiler
in the sense that the compiler does not allow to assign a velocity to a length
for example
we apply this in our AGV control software

i don't know if there already is something like this available in boost or
already proposed;
i can upload a version (not boostified) if someone is interested; free license
is no problem

renej

//*** Rene Jager - renej_at_[hidden] - www.frog.nl ***/


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