From: Eric Ford (eford_at_[hidden])
Date: 2001-10-04 19:41:24
Glad to see all the discussion about quantities, dimensions, units,
and qualifiers. I like the idea of a units library like SIunits, but
with a qualifier library on top. I whipped up a beast and uploaded it
to the qualified_unit folder. I hope people will take a look.
Basically, it provides strong typing for qualified units. By default
there's strong typing of qualifiers. If a user wants to allow adding
apples and oranges to give fruits, then they can specialize the the
promote_unit_qualifier traits-like class. They still can't assign
apples to oranges (or apples to fruits). However, iff the units
library allowed assigning a mass in kg to a weight in pounds (one unit
library might, another might not), then they could assign a
qualified_unit<pounds,apples_qualifier> to a
The test program includes it's own single-unit unit library, mainly
just to perform the most basic of tests. If you provide a real units
library, you'll need to change the typedef for type in
promote_unit<T1,T2,multiplies_op> and promote_unit<T1,T2,divides_op>
to give the type that that library returns when it multiplies/divides
quantities with units T1 and T2. Other than that, I hope it will
work, but I can't get SIunits to compile, so I there are probably
things I did wrong.
It still has a ways to go. For example, presently, it's not smart
about "canceling" qualifiers. E.g. if you divide 2 liters of coke by
2 liters of coke, it would give 1 [unitless] but with a unit qualifier
of (coke/coke) .
Also, it doesn't have a way to deal with power of qualifiers. In
principle this is probably necessary, although it can certainly wait.
Both these shortcomings would probably need to be addressed by using a
different data structure (currently a binary tree) to hold the
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk