John Moeller | 20 May 18:18
Picon

[math] pow redux and observations

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.

_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost


Gmane