
I would like to use boost::units in a new application that must interface to existing APIs that do not provide templated interfaces. What is the easiest way to use these existing functions that minimizes the copying of data from raw C pointers to a container that holds a specific type of boost::units?
On most compilers, the binary layout of quantity<Unit,Y> should be the same as that of the value type, Y, so you should be able to do something like this : std::vector<quantity<si::energy,double> > v(100); double *vp = reinterpret_cast<double*>(&v.front()); passing the resulting pointer to/from the legacy functions : do_something_in_legacy_code(vp); Naturally, you should verify that the layout is really compatible ... Matthias