mercredi 6 mai 2015

Ambiguous call to abs

I have a custom data type that in practice can be either float or double. On every OS except OSX, I am able to successfully build this C++11 template:

template< class REAL_T >
inline REAL_T inhouse_abs( REAL_T i_val )
{
    return (REAL_T)std::abs( (REAL_T)i_val );
}

However, clang 6.0 (3.5 LLVM) reports an ambiguous function call. If I change abs to fabs, the error is resolved on OSX, but now an identical error shows up on my Linux clang, gcc, and Visual Studio.

Any ideas?

Aucun commentaire:

Enregistrer un commentaire