fork(7) download
  1. #include <type_traits>
  2.  
  3. template<typename T, typename = void>
  4. struct is_equality_comparable : std::false_type
  5. { };
  6.  
  7. template<typename T>
  8. struct is_equality_comparable<T,
  9. typename std::enable_if<
  10. true,
  11. decltype((std::declval<T>() == std::declval<T>()), (void)0)
  12. >::type
  13. > : std::true_type
  14. {
  15. };
  16.  
  17. struct X { };
  18. struct Y { };
  19.  
  20. bool operator == (X const&, X const&) { return true; }
  21.  
  22. int main()
  23. {
  24. static_assert(is_equality_comparable<int>::value, "!");
  25. static_assert(is_equality_comparable<X>::value, "!");
  26. static_assert(is_equality_comparable<Y>::value, "!");
  27. }
  28.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp: In function ‘int main()’:
prog.cpp:26:9: error: static assertion failed: !
stdout
Standard output is empty