Boost 1.42 TR1 With GCC 4.5 selects wrong overload
I am using the portable style boost headers for tr1 implementation from
Boost 1.42 such as #include
I am using the portable style boost headers for tr1 implementation from Boost 1.42 such as #include
When i use gcc implementation of tr1 (Mingw GCC 4.5.1 from TDM, BOOST_HAS_GCC_TR1 defined) everything works fine. However when i select boost tr1 implementation (i.e not define the above macro) some stdlib functions such as std::abs gets wrong overloaded selected. For. e.g. in gcc/tr1 std::abs((signed char)5) returns an int while in boost/tr1 it returns a double.
A compilable example is like #include <cstdlib> #include <iostream> #include <typeinfo> #include
int main(){ std::cout< it happens with type_traits header (may be few other also) but not with all tr1 headers(such as array).
It's nothing to do with us, some TR1 headers just so happen to include <cmath> and in gcc-4.5 there is an abs overload that looks like: template<typename _Tp> inline typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, double>::__type abs(_Tp __x) { return __builtin_fabs(__x); } Which gets selected for all integer arguments other than int/long/long long. Whether this is C++0x conforming behavior though I'm not sure... HTH, John.
participants (2)
-
Abir Basak
-
John Maddock