Boost logo

Boost Users :

Subject: [Boost-users] [units] quantities with system abstraction "any<length>"
From: alfC (alfredo.correa_at_[hidden])
Date: 2010-10-06 04:31:45


Hi,

In order to avoid reinventing the wheel I was wondering if there is
any effort or there was any attempt to further abstract
boost::units::quantities from its unit system but with a given
dimension. That is, an object that can hold any
boost::units::quantity<unit<Dimension, System> > with a given
Dimension fir any System.

 For example (names are not ideal)

 any<length_dimension> a1 = 2.*si::meter; // RHS is type
quantity<si::length>
 any<length_dimension> a2 = 2.*cgs::centimeter; //RHS is type
quantity<cgs::length>
 any<length_dimension> b1 = 2.3 * si::second; // ERROR.

 or can hold any other quantity with length dimension (from any
system). A sort of boost::variant<quantity<Dimension, system1> ,
quantity<Dimension, system2>, ... >, (but since the list is of type is
not well defined maybe variant is not an options.)

I know that there are some unresolved issues, for example, what is the
result of a1 + a2, for which I have some solutions in mind. Anyway I
just was wondering if this was tried before. And if not, what would be
the best way to achieve it (boost::any? boost::variant?). (Note that
all quantity<Unit> types has always the sizeof a double.)

Alfredo


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net