Boost logo

Boost :

From: Deane Yang (deane_yang_at_[hidden])
Date: 2003-10-13 20:33:11

Hugo Duncan wrote:
> This is a problem with a library that we use here. It defines
> a quantity as a numeric type and a set of dimensions
> template <typename T, typename Dimensions> class quantity;
> where dimensions contains a mpl type sequence, with each
> element holding instances of
> template <
> typename DimensionType
> , long Numerator
> , long Denominator=1
> > struct dimension_power
> Each DimensionType is then assosciated with a unit.

This sounds like a very cool way to define a dimension/quantity/units
library. Is there any chance an implementation of this could be made
available? If not, could someone more fluent in MPL than me explain
how you would multiply two different quantities?

The cool thing about this approach is that you can multiply or
divide any two quantities and create a new dimension automatically.
The resulting typelist is a union of the original two typelists
with the Numerator and Denominator suitably updated.

Given enough time, I might be able to figure out how to generate the
resulting typelist from the two input typelists, but I'm happy to let
someone provide some hints or even answers.

Boost list run by bdawes at, gregod at, cpdaniel at, john at