#include <iostream>
#include <boost/units/quantity.hpp>
#include <boost/units/systems/si/length.hpp>
using namespace boost::units;
struct bu1 : base_unit<bu1, length_dimension, 2001> {};
struct bu2 : base_unit<bu2, length_dimension, 2002> {};
BOOST_UNITS_DEFINE_CONVERSION_FACTOR(bu1, bu2, double, 1.5);
#if 1
BOOST_UNITS_DEFINE_CONVERSION_FACTOR(bu2, bu1, double, 4.0);
#endif
int main(int argc, char *argv[])
{
quantity<bu1::unit_type> output(1 * bu2::unit_type());
// prints 4 or 0.67
std::cout << output.value() << std::endl;
return 0;
}
The code prints either 4
or 0.666667
depending on whether or not the second conversion factor is defined. Is this supposed to be by design? There are no two such units in physics that require different conversion factors, are there?