Quantcast

[units] quantities with system abstraction "any<length>"

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

[units] quantities with system abstraction "any<length>"

alfC
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 mailing list
[hidden email]
http://lists.boost.org/mailman/listinfo.cgi/boost-users
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [units] quantities with system abstraction "any<length>"

Steven Watanabe-4
  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 mailing list
[hidden email]
http://lists.boost.org/mailman/listinfo.cgi/boost-users
Loading...