Boost logo

Boost Users :

Subject: Re: [Boost-users] [units] quantities with system abstraction "any<length>"
From: Steven Watanabe (watanabesj_at_[hidden])
Date: 2010-10-13 15:31:52


  AMDG

On 10/6/2010 1:31 AM, alfC wrote:
> 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.

No. Boost.Units is strictly compile-time.

> 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.)

In Christ,
Steven Watanabe


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