Boost logo

Ublas :

From: Neal Becker (ndbecker2_at_[hidden])
Date: 2007-05-01 10:34:02


Neal Becker wrote:

> Thanks for adding abs to traits.hpp. I use vector<int>. This compiles
> fine
> on gcc-4.1.1, but not gcc-3.4.6. Any suggestions?
>

Looks like this will work. Problem is not just with <int>. Probably a problem with ADL?
#if __GNUG__ < 4
#include <boost/type_traits.hpp>
#include <boost/utility/enable_if.hpp>

namespace boost { namespace numeric { namespace ublas {
template<typename T>
inline typename enable_if_c<boost::is_arithmetic<T>::value, T>::type
abs(const T& x) { return (x >= 0) ? x : -x ; }
}}}
#endif