Boost logo

Boost :

From: Matthias Schabel (boost_at_[hidden])
Date: 2007-04-04 17:04:34


So this appears to work correctly (append this code to the end of
unit_example_15 and #include <boost/units/systems/si/length.hpp>) :

     // two-tier quantity for providing reference frame and
underlying unit safety
     typedef boost::array<quantity<SI::length>,3> vector_type;

     typedef quantity<world_space_unit,vector_type>
world_space_vector_type;
     typedef quantity<object_space_unit,vector_type>
object_space_vector_type;

     vector_type vec1 = { 0*SI::meter, 0*SI::meter, 0*SI::meter },
                 vec2 = { 1*SI::meter, 1*SI::meter, 1*SI::meter };

     world_space_vector_type wsv1 = vec1*world_space,
                                 wsv2 = vec2*world_space;
     object_space_vector_type osv1 = vec1*object_space,
                                 osv2 = vec2*object_space;

     world_space_vector_type wsv3(wsv1);
     object_space_vector_type osv3(osv1);

     world_space_vector_type wsv4(osv2);
     object_space_vector_type osv4(wsv2);

I believe this is the cleanest solution to your requirement for
reference frame conversions. The last two lines fail to compile now
because the conversion itself is not defined...just specialize
conversion_helper and you're off...

Matthias


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk