Boost logo

Boost :

From: John Moeller (fishcorn_at_[hidden])
Date: 2008-05-20 12:18:27


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.


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk