[units] runtime conversion approach
Units developers/user, I need some help understanding unit conversions using boost::units. I see there are conversions.hpp header files. Does this mean that there are built-in unit conversions for fundamental units, or even mainstream derived ones by simply including the conversions and performing the appropriate operation? Can I do something like this, for instance? quantitysi::length test_m = 1.0 * meter; quantityus::inch test_in = test_m * inch / meter; What is the best way to go about setting up conversions, or for that matter, defining a unit system; for instance, the us (english) unit system does not appear to be available? I've read a couple of the old mailing list entries, but I'm not sure I fully understand the examples that I could follow them. Thank you... Regards, Michael
I need some help understanding unit conversions using boost::units. I see there are conversions.hpp header files. Does this mean that there are built-in unit conversions for fundamental units, or even mainstream derived ones by simply including the conversions and performing the appropriate operation?
Can I do something like this, for instance?
quantitysi::length test_m = 1.0 * meter; quantityus::inch test_in = test_m * inch / meter;
You need to do conversions explicitly, so
#include <iosfwd>
#include <iostream>
#include
What is the best way to go about setting up conversions, or for that matter, defining a unit system; for instance, the us (english) unit system does not appear to be available?
As long as conversions between the base units you are using are defined, the conversions should just work. Study libs/units/examples/radar_beam_height.cpp - that should make it clearer... Matthias
participants (2)
-
Matthias Schabel
-
Michael Powell