greater_than.pass.cpp 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. //===----------------------------------------------------------------------===//
  2. //
  3. // The LLVM Compiler Infrastructure
  4. //
  5. // This file is dual licensed under the MIT and the University of Illinois Open
  6. // Source Licenses. See LICENSE.TXT for details.
  7. //
  8. //===----------------------------------------------------------------------===//
  9. // UNSUPPORTED: c++98, c++03, c++11, c++14
  10. // <optional>
  11. // template <class T> constexpr bool operator> (const optional<T>& x, const optional<T>& y);
  12. #include <optional>
  13. using std::optional;
  14. struct X
  15. {
  16. int i_;
  17. constexpr X(int i) : i_(i) {}
  18. };
  19. constexpr bool operator > ( const X &lhs, const X &rhs )
  20. { return lhs.i_ > rhs.i_ ; }
  21. int main()
  22. {
  23. {
  24. typedef optional<X> O;
  25. constexpr O o1; // disengaged
  26. constexpr O o2; // disengaged
  27. constexpr O o3{1}; // engaged
  28. constexpr O o4{2}; // engaged
  29. constexpr O o5{1}; // engaged
  30. static_assert ( !(o1 > o1), "" );
  31. static_assert ( !(o1 > o2), "" );
  32. static_assert ( !(o1 > o3), "" );
  33. static_assert ( !(o1 > o4), "" );
  34. static_assert ( !(o1 > o5), "" );
  35. static_assert ( !(o2 > o1), "" );
  36. static_assert ( !(o2 > o2), "" );
  37. static_assert ( !(o2 > o3), "" );
  38. static_assert ( !(o2 > o4), "" );
  39. static_assert ( !(o2 > o5), "" );
  40. static_assert ( (o3 > o1), "" );
  41. static_assert ( (o3 > o2), "" );
  42. static_assert ( !(o3 > o3), "" );
  43. static_assert ( !(o3 > o4), "" );
  44. static_assert ( !(o3 > o5), "" );
  45. static_assert ( (o4 > o1), "" );
  46. static_assert ( (o4 > o2), "" );
  47. static_assert ( (o4 > o3), "" );
  48. static_assert ( !(o4 > o4), "" );
  49. static_assert ( (o4 > o5), "" );
  50. static_assert ( (o5 > o1), "" );
  51. static_assert ( (o5 > o2), "" );
  52. static_assert ( !(o5 > o3), "" );
  53. static_assert ( !(o5 > o4), "" );
  54. static_assert ( !(o5 > o5), "" );
  55. }
  56. }