Boost logo

Boost :

From: Jeff Garland (jeff_at_[hidden])
Date: 2005-11-14 07:48:12

On Sun, 13 Nov 2005 21:36:38 -0800, Keith Nicewarner wrote
> Geoffrey Romer wrote:
> > Would there be any interest in a library for attaching units (physical
> > or otherwise) to numeric variables, so that the type system could
> > enforce dimension- and unit-consistency in all calculations, and
> > convert semi-automatically between compatible units?
> I'm fairly new to boost, so forgive my late entry into this
> discussion. I too recognized the need for this kind of library back
> in the late 90s and wrote this library available on SourceForge:
> It's pretty stable and used on several projects (there's a military
> simulation tool that has standardized on it). I've recently
> discovered the meta-programming method for dimensional quantities by
> Scott Meyers:
> This inspired me to revisit my library and it is turning out to be a
> fairly easy conversion. The old library had to explicitly represent
> each unit combination of interest (e.g., Speed = Length/Time), which
> is ugly and doesn't allow arbitrary combinations. The new method
> fixes all this (in fact, it simplifies things to the point where
> there is no library object file any more -- just headers).
> A key concept I tried to enforce is that any time the programmer
> sets or gets a numeric value, the specific units (i.e., Feet, Meters,
> etc.) must be specified. I don't want any units to be implicit.
> My library provides ostream formatting for handy printing. I also
> provide scalar, 2D, and 3D types. For the 2D/3D types, I provide
> various transformation operators like rotation. For 3D rotations, I
> provide the option of cosine matrix or unit quaternion.
> It's been suggested to me that I submit my library to boost. Being
> new to boost, I'm not sure how complete and tested the code needs to
> be. Any feedback or suggestions are welcome.

For the submission to be reviewed and accepted, the code will need to be
complete and coherent with good documentation. It doesn't have to have every
feature that can be imagined, but a useful core. Of course you can post early
working versions to the file vault for people to try out and provide feedback.
If you haven't already, take a read thru:

In the particular case of units, I'll just warn you that there is a trail of
broken dreams. There is clearly interest in such a library, but several
authors have started and then abandoned. You'll want to have a look thru the
mailing lists at some of the discussions we've had over the last 5 years or
so. I think Andy Little has come the closest to an actual submission. You
can find his library at:

Oh, and on the quaternion front, don't forget there's already boost.quaternion
- so maybe in a boost proposal it would be best to just use it?


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