Boost logo

Boost Users :

Subject: [Boost-users] Units: adding quantities
From: Mark Volkmann (mark_at_[hidden])
Date: 2009-01-09 17:23:56


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 list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net