Boost logo

Boost :

From: Terje Slettebø (tslettebo_at_[hidden])
Date: 2003-04-30 08:31:07

>From: <renej_at_[hidden]>

> > Even if angle is added as a dimension, to an implementation using an
> > integer vector, it still wouldn't accommodate any other dimensions
> > added later, without rewriting the library and unit definitions.
> how about having the basic SI dimensions and a couple of extra
> "to-be-defined-by-the-developer" dimensions. In that case, full
> SI "compliance" and for those who want something extra they can have
> it. I saw one of the discussed unit libraries provided something
> like a dimension to be defined by the user/developer.

I think I know a way this may be done, now: Default parameters.

There's several ways of specifying a unit; one is to use a typelist, such as
"typedef mpl::vector_c<1,0,0,0,0,0,0> kg" (Dave Abrahams also showed this
approach at the recent ACCU conference), or use template parameters for the
dimensions. In both ways, defaults may be used (it's used internally for
mpl::vector, anyway). In fact, all could be defaulted (like mpl::vector<>),
giving in this case a dimensionless unit.

Named template parameters could be a possibility, as well, so you could do
"typedef unit<kg<>, m<>, s<-2> > newton".



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