问题
I am trying to create a derived_dimension
in boost::units
for mass flow rate for si
system. I cannot find any documentation on how to do this simple task. This is what I have so far but I am getting errors during the compilation.
typedef boost::units::derived_dimension<
boost::units::mass_base_dimension, 3,
boost::units::time_base_dimension, -1
>::type mass_flow_rate_dimension;
typedef boost::units::unit<
mass_flow_rate_dimension,
boost::units::si::system
> mass_flow_rate_unit;
typedef boost::units::quantity<mass_flow_rate_unit, double> mass_flow_rate;
BOOST_UNITS_STATIC_CONSTANT(kilogram_per_seconds, mass_flow_rate);
This is how I get the error:
mass_flow_rate MFR;
quantity<mass_density> density = 1.0 * kilogram_per_cubic_meter;
quantity<si::time> Time = 1.0 * second;
quantity<volume> vol = 1.0 * cubic_meters;
MFR = density * vol / Time;
error: C2338 (is_simply_convertible::value == true)
回答1:
mass_flow_rate_dimension
has the wrong dimensions. You have mass to the third instead of just mass
typedef boost::units::derived_dimension<
boost::units::mass_base_dimension, 1,
boost::units::time_base_dimension, -1
>::type mass_flow_rate_dimension;
Fixes it. That error is meant just for the case when your dimensions don't line up.
来源:https://stackoverflow.com/questions/41750974/how-to-properly-define-a-derived-unit-in-boost-unit