AMDG On 11/19/2018 09:09 PM, Matt Vinson via Boost-users wrote:
Eisuke Kawashima: Thank You. I'll have a look. When I saw Boost.Units did not have imperial and we had to create it ourselves, I thought: the US is s 5 trillion dollar market, most of those markets need programming, all are on imperial. Boost.Units needs imperial and programmers would find and use it.
Steven Watanabe: Thank You. This solution doesn't seem correct as it does not consider "length"....
How is it wrong? length cancels out. The divides version will give exactly the same type.
boost::units::derived_dimension< boost::units::mass_base_dimension, 1, boost::units::time_base_dimension, -2>::typeI thought I'd at it (L M T^-2 L-1) but this didn't do well.: typedef boost::units::derived_dimension< boost::units::length_base_dimension, 1, boost::units::mass_base_dimension, 1, boost::units::time_base_dimension, -2, boost::units::length_base_dimension, -1 >::type lineal_force_dimension;
derived_dimension can't handle multiple uses of the same base dimension. Even if it did, it would just cancel them out, so this serves to purpose.
So, I tried the " typedef boost::mpl::divides<...>" solution as it has force and length. I am closer, I hope. *.h------------------------------------------------------------------------------------------------------------------------------------------ namespace dimensional_analysis { typedef boost::units::length_base_dimension::dimension_type length_dimension; typedef boost::units::mass_base_dimension::dimension_type mass_dimension;
typedef boost::units::make_system< boost::units::us::inch_base_unit, boost::units::us::pound_base_unit >::type ip_system;
namespace lineal_force { typedef boost::mpl::divides< boost::units::force_dimension, boost::units::length_dimension>::type lineal_force_dimension; namespace imperial { typedef boost::units::unit< lineal_force_dimension, dimensional_analysis ::ip_system > lineal_force_unit; typedef boost::units::quantity
pound_per_in_quantity; BOOST_UNITS_STATIC_CONSTANT(pound_per_inch, pound_per_in_quantity); } namespace si { typedef boost::units::unit< lineal_force_dimension, boost::units::si::system > lineal_force_unit;
This is not the unit you want. The SI unit of force is N, not kg. kilogram-force is not currently provided by Boost.Units and you'll need to define it yourself. (As in your previous post.)
typedef boost::units::quantity
kg_per_meter_quantity; BOOST_UNITS_STATIC_CONSTANT(kg_per_meter, kg_per_meter_quantity); } }//lineal_force }//dimensional_analysis <snip>
In Christ, Steven Watanabe