From: Ben FrantzDale (frantb_at_[hidden])
Date: 2007-01-18 20:28:25


On 1/18/07, Matthias Schabel <boost_at_[hidden]> wrote:
>
> ...
> 3) implemented quantity_cast for three cases (see unit_example_5.cpp) :
> a) construction of quantities from raw value types
> b) conversion of value_types
> c) conversion of unit systems
>

It isn't clear to me what the semantics of these three are. I'd
quantity_cast should be a dimensionally safe operation. Is that the
semantics you have in mind?

It seems like (a) should just be handled by multiplication. That is,
  double x = 42.0;
  quantity<SI::length> y = x * SI::meter;
For (b), it might be better to have a static_quantity_cas, as in
  quantity<SI::length> x = 42.0 * SI::meter;
  quantity<SI::length, int> y = static_quantity_cast<quantity<SI::length,
int> >(x);
For (c), do you mean this:
  quantity<SI::length> x = 42.0 * SI::meter;
  quantity<CGS::length> y = quantity_cast<quantity<CGS::length> >(x);
where y ends up being 4200 cm?

—Ben

PS
I must say I'm thrilled to see someone putting serious effort into this.
I've thought about it for years.