I'm trying to check if a class has a method operator==
. I found a solution with SFINAE here and it's working fine with the class I make.
It looks like this :
template <typename T>
class comparable
{
typedef char one;
typedef long two;
template <typename C> static one test( typeof(&C::operator==) ) ;
template <typename C> static two test(...);
public:
enum { value = sizeof(test<T>(0)) == sizeof(char) };
};
But, when I try :
std::cout << comparable<int>::value << std::endl;
Then it returns false while I was expecting it to return true. Why is this ?