// takes any unit of length
template<class System>
void setX(quantity<unit<length_dimension,System> > const& x) {
// explicit conversion to si::length = meters
m_X = quantity<si::length>(x);
Is the following set of statements correct. si::length has a length_dimension and is part of the si::system. boost::units::si::meter_base_unit::unit_type has a length_dimension and is part of the si::system. boost::units::us::foot_base_unit::unit_type has a length_dimension and is part of the us system.
Since an explicit conversion is needed I definitely don't understand the differences between the following three statements. I've included examples to show my limited understanding.
implicit conversion of quantity<Unit,Y>
to quantity<Unit,Z>
is allowed if Y
and Z
are implicitly convertible.
quantity<si::length, int> to quantity<si::length, double>
explicit conversion between quantity<Unit1,Y>
and quantity<Unit2,Z>
is allowed if Unit1
and Unit2
have the same dimensions and if Y
and Z
are implicitly convertible.
quantity<us::foot_base_unit::unit_type, int> to quantity<si::length, double>
Both have the same length dimension.
implicit conversion between quantity<Unit1,Y>
and quantity<Unit2,Z>
is allowed if Unit1
reduces to exactly the same combination of base units as Unit2
and if Y
and Z
are convertible.
I'm not sure on the example for this one.
Ryan