From: John Maddock (john_at_[hidden])
Date: 2008-05-20 12:57:23
John Moeller wrote:
> I noticed that the trunk now has corrections for pow<N> to reduce
> template instantiations. However, the "N=1" specialization isn't
> correct. The second template parameter (bool odd) should be "true,"
> not "false." I could be mistaken that 1 is an odd number, though.
> As it is now, the whole template would work, but would ignore the
> 1/false specialization and create a new 1/true specialization that
> just multiplies "base" by the result of 0/false. Changing 1/false to
> 1/true will just cause it to return "base," as desired.
> Note also, please, that positive_power<0,false> returns 1 when base
> is 0. Since 0^0 is technically undefined, the "N=0" case should
> probably be handled at a higher level (in power_if_positive,
> perhaps), and cause an error, just like negative powers of 0. If
> that is done, the 0/false case could be removed from positive_power.
Right. I've fixed the partial specialization buglet, but please note that
the current version is really just a stopgap: there have been many excellent
suggestions on this list, and if Bruno can wrap them all together into a new
improved version, that would probably be the best solution.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk