Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / libcxx / test / std / utilities / optional / optional.relops / greater_than.pass.cpp
blob6b877c3011cb0f36e891bc63ba5dcd6c8705c25e
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 //===----------------------------------------------------------------------===//
9 // UNSUPPORTED: c++03, c++11, c++14
10 // <optional>
12 // template <class T, class U> constexpr bool operator> (const optional<T>& x, const optional<U>& y);
14 #include <optional>
16 #include "test_macros.h"
18 using std::optional;
20 struct X {
21 int i_;
23 constexpr X(int i) : i_(i) {}
26 constexpr bool operator>(const X& lhs, const X& rhs) { return lhs.i_ > rhs.i_; }
28 int main(int, char**) {
30 typedef optional<X> O;
32 constexpr O o1; // disengaged
33 constexpr O o2; // disengaged
34 constexpr O o3{1}; // engaged
35 constexpr O o4{2}; // engaged
36 constexpr O o5{1}; // engaged
38 static_assert(!(o1 > o1), "");
39 static_assert(!(o1 > o2), "");
40 static_assert(!(o1 > o3), "");
41 static_assert(!(o1 > o4), "");
42 static_assert(!(o1 > o5), "");
44 static_assert(!(o2 > o1), "");
45 static_assert(!(o2 > o2), "");
46 static_assert(!(o2 > o3), "");
47 static_assert(!(o2 > o4), "");
48 static_assert(!(o2 > o5), "");
50 static_assert((o3 > o1), "");
51 static_assert((o3 > o2), "");
52 static_assert(!(o3 > o3), "");
53 static_assert(!(o3 > o4), "");
54 static_assert(!(o3 > o5), "");
56 static_assert((o4 > o1), "");
57 static_assert((o4 > o2), "");
58 static_assert((o4 > o3), "");
59 static_assert(!(o4 > o4), "");
60 static_assert((o4 > o5), "");
62 static_assert((o5 > o1), "");
63 static_assert((o5 > o2), "");
64 static_assert(!(o5 > o3), "");
65 static_assert(!(o5 > o4), "");
66 static_assert(!(o5 > o5), "");
69 using O1 = optional<int>;
70 using O2 = optional<long>;
71 constexpr O1 o1(42);
72 static_assert(o1 > O2(1), "");
73 static_assert(!(O2(42) > o1), "");
76 using O1 = optional<int>;
77 using O2 = optional<const int>;
78 constexpr O1 o1(42);
79 static_assert(o1 > O2(1), "");
80 static_assert(!(O2(42) > o1), "");
83 return 0;