From: Steven Watanabe (watanabesj_at_[hidden])
Date: 2008-02-02 16:48:39
Bruno Lalande wrote:
> Hi Joaquin,
> Yes you're right, thanks for the advice. I really thought that an optimizing
> compiler was able to figure out this by itself, that is, transform things
> like n*n*n*n into (n*n)*(n*n). But a few tests shew me I was wrong.
> With your modification the function is finally much more than a syntactic
> helper since it runs faster than what an average programmer would type by
> hand. Shouldn't it be integrated somewhere into Boost ?
There's such a function in Boost.Units. It was originally needed
the result type depends on the exponent which must therefore be known at
boost::units::quantity<boost::units::SI::area> area =
boost::units::pow<2>(3.0 * boost::units::SI::meters);
Note that this is not in the trunk yet.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk