
Hello, Here is a new version of the pow.hpp file with updated tests and docs. It nows handles errors using the Boost.Math overflow error policy, and uses promote_args to determine the return type. I've tested it on the same platforms as before, BUT it no longer compiles with gcc-2.95.4. The first reason was that policy.hpp includes <limits> that gcc 2.95 doesn't have so I replaced it by <boost/limits.hpp> and it worked, but some other Boost files include other headers that are also missing (ios for instance, included in lcast_precision.hpp). Is the support for that compiler required? Bruno On Feb 15, 2008 10:49 AM, Bruno Lalande <bruno.lalande@gmail.com> wrote:
Hello,
"These rules are chosen to be compatible with the behaviour of
ISO/IEC 9899:1999 Programming languages - C and with the Draft Technical Report on C++ Library Extensions, 2005-06-24, section 5.2.1, paragraph 5.
http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2005/n1836.pdf "
Right the idea is to be compatible with what C99 and C++0x do when an integer argument is passed to a math function.
OK I have read this section of the draft and now I understand better the purpose of promote_args, so I will use it in order to to be C99 and C++0x compliant.
The other issue is that if:
pow<-3>(2)
returned an integer, then presumably it can only return 0, which isn't exactly right :-)
Just to see if it was even possible, I've implemented what I had talked about before. It takes this issue into account. Basically, here is the output of my test program with the result of pow on several types and their corresponding typeids: pow<2>(2) = (i)4 pow<2>(2.0) = (d)4 pow<2>(2.0f) = (f)4 pow<-2>(2) = (d)0.25 pow<-2>(2.0) = (d)0.25 pow<-2>(2.0f) = (d)0.25 And regarding the way in which I did it, I "guess" a use with Boost.Unitswould give the expected result. Something like: pow<3>((length)5) = (volume)125;
But the most important is to implement the promote_args version. I will provide this soon. After that we can always propose, as Paul said, a special version with a different name.
Regards Bruno