
-----Original Message----- From: boost-bounces@lists.boost.org [mailto:boost-bounces@lists.boost.org] On Behalf Of Lewis Hyatt Sent: Thursday, March 29, 2007 4:36 PM To: boost@lists.boost.org Subject: Re: [boost] units: review
Eric Lemings wrote:
quantity<SI::length> l1(2.0 * SI::meters); quantity<SI::length> l2(2.0 * Astro::parsecs); //for illustration only
I would express that differently:
quantity<SI::length> l1 (quantity<SI::meter>(2.0)); quantity<SI::length> l2 (quantity<Astro::parsecs>(2.0)); //for illustration only
And I could be way off base here but the latter form would appear more familiar/acceptable to most C++ programmers.
I think it is perfectly natural to think of units as having their own algebra, and so the multiplication notation makes sense. How would you do something like this:
quantity<velocity> v(2.0 * meters/second);
in your method? I think you'll find that this one is preferable.
quantity<velocity> v1 (quantity<meter>(2) / quantity<second>(1)); //or quantity<meter> m(2); quantity<second> s(1); quantity<velocity> v2(m/s); The problem with the "multiplier" usage is it uses a unit name (plural, singular, whatever) for both type information and rvalue expressions. quantity<second[s]> t1 (2.0 * second[s]); This usage may be preferable to scientists and engineers but not C++ programmers, I'll gar-on-tee. Eric.