fork(2) download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. template <typename Derived>
  5. struct Comparisons
  6. {
  7. };
  8.  
  9.  
  10. template <typename Derived>
  11. bool operator!=(const Comparisons<Derived>& lhs, const Comparisons<Derived>& rhs)
  12. {
  13. const Derived& d1 = static_cast<const Derived&>(lhs);
  14. const Derived& d2 = static_cast<const Derived&>(rhs);
  15.  
  16. return !(d1 == d2);
  17. }
  18.  
  19. struct Test : Comparisons<Test>
  20. {
  21. friend bool operator==(const Test& t1, const Test& t2)
  22. {
  23. return true;
  24. }
  25. };
  26.  
  27. int main()
  28. {
  29. Test t1, t2;
  30.  
  31. bool b = t1 != t2;
  32.  
  33. return 0;
  34. }
Success #stdin #stdout 0s 4300KB
stdin
Standard input is empty
stdout
Standard output is empty