Hi,
I asked about this in
StackOverflow but didn't get any answers so I thought I'd try here as well.
I need to create a unit which represents pressure per time, specifically Bar per Minute. I tried creating it in the same way as I created similar units before:
typedef boost::units::derived_dimension<boost::units::length_base_dimension,
-1,
boost::units::mass_base_dimension,
1,
boost::units::time_base_dimension, -3>::type
pressure_roc_dimension;
typedef boost::units::unit<pressure_roc_dimension,
boost::units::make_system<boost::units::metric::bar_base_unit,
boost::units::metric::minute_base_unit>::type> bar_per_minute_unit;
BOOST_UNITS_STATIC_CONSTANT(BarPerMinute,
bar_per_minute_unit::unit_type);
typedef boost::units::quantity<bar_per_minute_unit,
double>
BarPerMinuteRoC;
And then I try to use it:
BarPerMinuteRoC bpm
= 5.0 *
BarPerMinute;
But this line doesn't compile with quite a long error trail which I'm having a bit of trouble understanding fully.
1>c:\workspace\externals\boost_1_57_0\include\boost\units\detail\linear_algebra.hpp(197):
error C2039: 'item'
: is
not a member
of 'boost::units::dimensionless_type'
1> c:\workspace\externals\boost_1_57_0\include\boost\units\dimensionless_type.hpp(37)
: see declaration of 'boost::units::dimensionless_type'
1> c:\workspace\externals\boost_1_57_0\include\boost\units\detail\linear_algebra.hpp(259)
: see reference to class
template instantiation
'boost::units::detail::determine_extra_equations_skip_zeros_impl<true,false>::apply<RowsBegin,1,1,3,Result>'
being compiled
1>
with
1> [
1> RowsBegin=boost::units::list<boost::units::list<boost::units::static_rational<0,1>,boost::units::list<boost::units::static_rational<1,1>,boost::units::detail::make_zero_vector<0>::type>>,boost::units::detail::determine_extra_equations_skip_zeros_impl<false,true>::apply<boost::units::list<boost::units::list<boost::units::static_rational<-1,1>,boost::units::list<boost::units::static_rational<1,1>,boost::units::list<boost::units::static_rational<-2,1>,boost::units::detail::expand_dimensions<0>::apply<boost::units::dimensionless_type,boost::units::dimensionless_type>::type>>>,boost::units::dimensionless_type>,1,0,3,boost::units::list<boost::units::list<boost::units::static_rational<0,1>,boost::units::list<boost::units::static_rational<0,1>,boost::units::list<boost::units::static_rational<1,1>,boost::units::detail::make_zero_vector<0>::type>>>,boost::units::list<boost::units::list<boost::units::static_rational<-1,1>,boost::units::list<boost::units::static_rational<1,1>,boost::units::list<boost::units::static_rational<-2,1>,boost::units::detail::expand_dimensions<0>::apply<boost::units::dimensionless_type,boost::units::dimensionless_type>::type>>>,boost::units::dimensionless_type>>>::next_equations>
1> ,
Result=boost::units::list<boost::units::list<boost::units::static_rational<0,1>,boost::units::list<boost::units::static_rational<0,1>,boost::units::list<boost::units::static_rational<1,1>,boost::units::detail::make_zero_vector<0>::type>>>,boost::units::list<boost::units::list<boost::units::static_rational<-1,1>,boost::units::list<boost::units::static_rational<1,1>,boost::units::list<boost::units::static_rational<-2,1>,boost::units::detail::expand_dimensions<0>::apply<boost::units::dimensionless_type,boost::units::dimensionless_type>::type>>>,boost::units::dimensionless_type>>
1> ]
1> c:\workspace\externals\boost_1_57_0\include\boost\units\detail\linear_algebra.hpp(264)
: see reference to class
template instantiation
'boost::units::detail::determine_extra_equations<2,false>::apply<boost::units::list<boost::units::list<boost::units::static_rational<0,1>,boost::units::list<boost::units::static_rational<1,1>,boost::units::detail::make_zero_vector<0>::type>>,boost::units::detail::determine_extra_equations_skip_zeros_impl<false,true>::apply<boost::units::list<boost::units::list<boost::units::static_rational<-1,1>,boost::units::list<boost::units::static_rational<1,1>,boost::units::list<boost::units::static_rational<-2,1>,boost::units::detail::expand_dimensions<0>::apply<boost::units::dimensionless_type,boost::units::dimensionless_type>::type>>>,boost::units::dimensionless_type>,1,0,3,Result>::next_equations>,3,Result>'
being compiled
1>
with
1> [
1>
Result=boost::units::list<boost::units::list<boost::units::static_rational<0,1>,boost::units::list<boost::units::static_rational<0,1>,boost::units::list<boost::units::static_rational<1,1>,boost::units::detail::make_zero_vector<0>::type>>>,boost::units::list<boost::units::list<boost::units::static_rational<-1,1>,boost::units::list<boost::units::static_rational<1,1>,boost::units::list<boost::units::static_rational<-2,1>,boost::units::detail::expand_dimensions<0>::apply<boost::units::dimensionless_type,boost::units::dimensionless_type>::type>>>,boost::units::dimensionless_type>>
1> ]
1> c:\workspace\externals\boost_1_57_0\include\boost\units\detail\linear_algebra.hpp(538)
: see reference to class
template instantiation
'boost::units::detail::determine_extra_equations<3,false>::apply<Matrix,3,Matrix>'
being compiled
1>
with
1> [
1>
Matrix=boost::units::list<boost::units::list<boost::units::static_rational<0,1>,boost::units::list<boost::units::static_rational<0,1>,boost::units::list<boost::units::static_rational<1,1>,boost::units::detail::make_zero_vector<0>::type>>>,boost::units::list<boost::units::list<boost::units::static_rational<-1,1>,boost::units::list<boost::units::static_rational<1,1>,boost::units::list<boost::units::static_rational<-2,1>,boost::units::detail::expand_dimensions<0>::apply<boost::units::dimensionless_type,boost::units::dimensionless_type>::type>>>,boost::units::dimensionless_type>>
1> ]
1> c:\workspace\externals\boost_1_57_0\include\boost\units\detail\linear_algebra.hpp(828)
: see reference to class
template instantiation
'boost::units::detail::make_square_and_invert<boost::units::list<boost::units::list<boost::units::static_rational<0,1>,boost::units::list<boost::units::static_rational<0,1>,boost::units::list<boost::units::static_rational<1,1>,boost::units::detail::make_zero_vector<0>::type>>>,boost::units::list<boost::units::list<boost::units::static_rational<-1,1>,boost::units::list<boost::units::static_rational<1,1>,boost::units::list<boost::units::static_rational<-2,1>,boost::units::detail::expand_dimensions<0>::apply<boost::units::dimensionless_type,boost::units::dimensionless_type>::type>>>,boost::units::dimensionless_type>>>'
being compiled
1> c:\workspace\externals\boost_1_57_0\include\boost\units\detail\linear_algebra.hpp(1032)
: see reference to class
template instantiation
'boost::units::detail::normalize_units<T>'
being compiled
1>
with
1> [
1> T=boost::units::list<boost::units::scaled_base_unit<boost::units::si::second_base_unit,boost::units::scale<60,boost::units::static_rational<1,1>>>,boost::units::list<boost::units::metric::bar_base_unit,boost::units::dimensionless_type>>
1> ]
1> c:\workspace\externals\boost_1_57_0\include\boost\units\detail\linear_algebra.hpp(1051)
: see reference to class
template instantiation
'boost::units::detail::calculate_base_unit_exponents_impl<false>::apply<T,Dimensions>'
being compiled
1> with
1> [
1> T=boost::units::list<boost::units::scaled_base_unit<boost::units::si::second_base_unit,boost::units::scale<60,boost::units::static_rational<1,1>>>,boost::units::list<boost::units::metric::bar_base_unit,boost::units::dimensionless_type>>
1> ,
Dimensions=BSII::Units::pressure_roc_dimension
1> ]
1> c:\workspace\externals\boost_1_57_0\include\boost\units\heterogeneous_system.hpp(243)
: see reference to class
template instantiation
'boost::units::detail::calculate_base_unit_exponents<boost::units::list<boost::units::scaled_base_unit<boost::units::si::second_base_unit,boost::units::scale<60,boost::units::static_rational<1,1>>>,boost::units::list<T,boost::units::dimensionless_type>>,Dimensions>'
being compiled
1>
with
1> [
1> T=boost::units::metric::bar_base_unit
1> ,
Dimensions=BSII::Units::pressure_roc_dimension
1> ]
1> c:\workspace\externals\boost_1_57_0\include\boost\units\unit.hpp(92)
: see reference to class
template instantiation
'boost::units::detail::make_heterogeneous_system<Dim,System>'
being compiled
1>
with
1> [
1>
Dim=BSII::Units::pressure_roc_dimension
1> ,
System=boost::units::homogeneous_system<boost::units::list<boost::units::scaled_base_unit<boost::units::si::second_base_unit,boost::units::scale<60,boost::units::static_rational<1,1>>>,boost::units::list<boost::units::metric::bar_base_unit,boost::units::dimensionless_type>>>
1> ]
1> c:\workspace\externals\boost_1_57_0\include\boost\units\unit.hpp(99)
: see reference to class
template instantiation
'boost::units::reduce_unit<S1>'
being compiled
1> with
1> [
1> S1=BSII::Units::bar_per_minute_unit
1> ]
1> c:\workspace\foundations\sw_foundations\bsii_common\test\src\units\units_pressure_test.cpp(97)
: see reference to class
template instantiation
'boost::units::is_implicitly_convertible<BSII::Units::bar_per_minute_unit,Unit>'
being compiled
1>
with
1> [
1>
Unit=BSII::Units::bar_per_minute_unit
1> ]
According to the Boost documentation a homogeneous system can only be composed of linearly independent base units. In my case, I'm trying to mix bars (which in turn "contain" seconds
as the time element) with minutes. This sounds problematic to me. But on the other hand, since I don't include mass and length base units in my system it seems to me that the base is independent after all.
In any case, I searched online for an example of creating such a heterogeneous unit but didn't find anything comprehensible. Also, I read in the Boost documentation that a heterogeneous
unit doesn't preserve information about how it was created. Does this mean I won't be able to, for instance, multiply BarPerMinuteRoC by Minute and get Bar back?
Thanks a lot!
Dina