[cfe-users] Ambigous function call with template

Florian Lindner mailinglists at xgm.de
Thu Jul 17 01:54:24 PDT 2014


Florian Lindner wrote:

> Hello,
> 
> I have a piece of code that works perfectly with recent versions of g++
> but fails to compile with clang++. I try to understand why.
> 
> ScalarOperations.h:
> 
>     template<typename Type>
>       typename utils::EnableIf<(not IsVector<Type>::value),
>       bool
>     >::Type smallerEquals (
>       Type lhs,
>       Type rhs,
>       Type tolerance = NUMERICAL_ZERO_DIFFERENCE);
> 
> ScalarOperations.cpph:
> 
> template<typename Type>
>   inline
>   typename utils::EnableIf<not IsVector<Type>::value,
>   bool
>>::Type smallerEquals (
>   Type lhs,
>   Type rhs,
>   Type tolerance
> ) {
>   return lhs - rhs <= tolerance;
> }
> 
> 
> this is called from ScalarTest.cpp like that:
> 
> #include "code.h"
> 
> double a = 1.0;
> double b = 2.0;
> double eps = 1e-14;
> validate (smallerEquals(a, b, eps));

Amendment: I have a identical function "smaller" (just the operator is not 
<= but <) which is called before smallerEquals and does not fail.

Thanks!
Florian




More information about the cfe-users mailing list