rel_ops.pass.cpp 971 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. //===----------------------------------------------------------------------===//
  2. //
  3. // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
  4. // See https://llvm.org/LICENSE.txt for license information.
  5. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  6. //
  7. //===----------------------------------------------------------------------===//
  8. // test rel_ops
  9. #include <utility>
  10. #include <cassert>
  11. #include "test_macros.h"
  12. struct A
  13. {
  14. int data_;
  15. explicit A(int data = -1) : data_(data) {}
  16. };
  17. inline
  18. bool
  19. operator == (const A& x, const A& y)
  20. {
  21. return x.data_ == y.data_;
  22. }
  23. inline
  24. bool
  25. operator < (const A& x, const A& y)
  26. {
  27. return x.data_ < y.data_;
  28. }
  29. int main(int, char**)
  30. {
  31. using namespace std::rel_ops;
  32. A a1(1);
  33. A a2(2);
  34. assert(a1 == a1);
  35. assert(a1 != a2);
  36. assert(a1 < a2);
  37. assert(a2 > a1);
  38. assert(a1 <= a1);
  39. assert(a1 <= a2);
  40. assert(a2 >= a2);
  41. assert(a2 >= a1);
  42. return 0;
  43. }