David Abrahams wrote:
"Jeff Garland" <[EMAIL PROTECTED]> writes:Many of the regression tests for the date time library are failing currently because the library relies on std::abs<long long> being available. AKAIK, the C++ standard doesn't require this so the library shouldn't make use of it. Maybe datetime should specify it's own version of abs like this: #include <cstdlib> #include <stdlib.h>
>>>
Looks like there a two cases which would need two macros.template <typename T> T abs(T i) { return std::abs(i); } template <> long long abs(long long i) {return ::llabs(i); }
Take a look at bosot/date_time/compiler_config.hpp which does something similar. All we need to do to fix these regressions is add the compiler to the list of those that don't have std::abs at line 34. Turns out that some compilers that support long long do define a version of abs for long long. (I'm sure you also know that some compilers don't call it the type long long either which is why we have boost::int64_t). Just as an aside, at some point this logic should likely move out of date_time and into the general config somewhere so that others can access std::abs on these types if they need.AFAICT the logic is backwards: you should assume there's no std::abs which works on long long and use your own function by default, only using std::abs if the compiler is *known* to support that extension... if it's even worth the trouble (it'll be less code to just do the whole thing yourself).
- BOOST_NO_STD_ABS identifies that no std::abs is available.
- BOOST_HAS_STD_ABS_LONG_LONG identifies that the compiler provides a long long overload for std::abs.
Those macro names follow the general macro naming convention, I think.
The easiest thing would probably be to just say
namespace whatever { inline template <class T> T abs(T) { ... } }
and use this, as Dave suggested.
Markus
_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
