
On Jan 9, 2009, at 4:41 PM,
I would not want to write any software that internally calculates with non-metric units.
Agreed. I wouldn't either. I'm just trying to learn how to use this library now. The actual units aren't relevant to my questions. Suppose I had a method that accepted meters and I had quantities of meters and centimeters. How can I add two quantities that have different, but related units? Obviously I could get the primitive values, multiple centimeters by 100, add that to the number of meters and create a new quantity. I just want to know if and how the Units library helps with adding quantities of different units.
-----Original Message----- From: boost-users-bounces@lists.boost.org [mailto:boost-users-bounces@lists.boost.org ] On Behalf Of Mark Volkmann Sent: Friday, January 09, 2009 14:24 To: Boost-users@lists.boost.org Subject: [Boost-users] Units: adding quantities
I have a method that takes a parameter of type quantity<feet> where feet is defined by the following typedef:
typedef boost::units::us::foot_base_unit::unit_type feet;
I also have this typedef:
typedef bu::us::inch_base_unit::unit_type inches;
Do I really need to define a typedef like this for every measurement type I want to use? I certainly don't want to specify all those namespaces every time I use one of the measurement types, but this approach seems a bit tedious.
I'd like to do something like this:
a.setWingspan(195*feet() + 8*inches());
but that doesn't work because there is no match for operator+.
What's a good way to add inches to a feet quantity?
--- Mark Volkmann
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
--- Mark Volkmann