1*4684ddb6SLionel Sambuc //===----------------------------------------------------------------------===//
2*4684ddb6SLionel Sambuc //
3*4684ddb6SLionel Sambuc // The LLVM Compiler Infrastructure
4*4684ddb6SLionel Sambuc //
5*4684ddb6SLionel Sambuc // This file is dual licensed under the MIT and the University of Illinois Open
6*4684ddb6SLionel Sambuc // Source Licenses. See LICENSE.TXT for details.
7*4684ddb6SLionel Sambuc //
8*4684ddb6SLionel Sambuc //===----------------------------------------------------------------------===//
9*4684ddb6SLionel Sambuc
10*4684ddb6SLionel Sambuc // <optional>
11*4684ddb6SLionel Sambuc
12*4684ddb6SLionel Sambuc // template <class T> constexpr bool operator==(const optional<T>& x, const optional<T>& y);
13*4684ddb6SLionel Sambuc
14*4684ddb6SLionel Sambuc #include <experimental/optional>
15*4684ddb6SLionel Sambuc #include <type_traits>
16*4684ddb6SLionel Sambuc #include <cassert>
17*4684ddb6SLionel Sambuc
18*4684ddb6SLionel Sambuc #if _LIBCPP_STD_VER > 11
19*4684ddb6SLionel Sambuc
20*4684ddb6SLionel Sambuc using std::experimental::optional;
21*4684ddb6SLionel Sambuc
22*4684ddb6SLionel Sambuc struct X
23*4684ddb6SLionel Sambuc {
24*4684ddb6SLionel Sambuc int i_;
25*4684ddb6SLionel Sambuc
XX26*4684ddb6SLionel Sambuc constexpr X(int i) : i_(i) {}
27*4684ddb6SLionel Sambuc };
28*4684ddb6SLionel Sambuc
operator ==(const X & lhs,const X & rhs)29*4684ddb6SLionel Sambuc constexpr bool operator == ( const X &lhs, const X &rhs )
30*4684ddb6SLionel Sambuc { return lhs.i_ == rhs.i_ ; }
31*4684ddb6SLionel Sambuc
32*4684ddb6SLionel Sambuc #endif
33*4684ddb6SLionel Sambuc
main()34*4684ddb6SLionel Sambuc int main()
35*4684ddb6SLionel Sambuc {
36*4684ddb6SLionel Sambuc #if _LIBCPP_STD_VER > 11
37*4684ddb6SLionel Sambuc {
38*4684ddb6SLionel Sambuc typedef X T;
39*4684ddb6SLionel Sambuc typedef optional<T> O;
40*4684ddb6SLionel Sambuc
41*4684ddb6SLionel Sambuc constexpr O o1; // disengaged
42*4684ddb6SLionel Sambuc constexpr O o2; // disengaged
43*4684ddb6SLionel Sambuc constexpr O o3{1}; // engaged
44*4684ddb6SLionel Sambuc constexpr O o4{2}; // engaged
45*4684ddb6SLionel Sambuc constexpr O o5{1}; // engaged
46*4684ddb6SLionel Sambuc
47*4684ddb6SLionel Sambuc static_assert ( o1 == o1 , "" );
48*4684ddb6SLionel Sambuc static_assert ( o1 == o2 , "" );
49*4684ddb6SLionel Sambuc static_assert ( !(o1 == o3), "" );
50*4684ddb6SLionel Sambuc static_assert ( !(o1 == o4), "" );
51*4684ddb6SLionel Sambuc static_assert ( !(o1 == o5), "" );
52*4684ddb6SLionel Sambuc
53*4684ddb6SLionel Sambuc static_assert ( o2 == o1 , "" );
54*4684ddb6SLionel Sambuc static_assert ( o2 == o2 , "" );
55*4684ddb6SLionel Sambuc static_assert ( !(o2 == o3), "" );
56*4684ddb6SLionel Sambuc static_assert ( !(o2 == o4), "" );
57*4684ddb6SLionel Sambuc static_assert ( !(o2 == o5), "" );
58*4684ddb6SLionel Sambuc
59*4684ddb6SLionel Sambuc static_assert ( !(o3 == o1), "" );
60*4684ddb6SLionel Sambuc static_assert ( !(o3 == o2), "" );
61*4684ddb6SLionel Sambuc static_assert ( o3 == o3 , "" );
62*4684ddb6SLionel Sambuc static_assert ( !(o3 == o4), "" );
63*4684ddb6SLionel Sambuc static_assert ( o3 == o5 , "" );
64*4684ddb6SLionel Sambuc
65*4684ddb6SLionel Sambuc static_assert ( !(o4 == o1), "" );
66*4684ddb6SLionel Sambuc static_assert ( !(o4 == o2), "" );
67*4684ddb6SLionel Sambuc static_assert ( !(o4 == o3), "" );
68*4684ddb6SLionel Sambuc static_assert ( o4 == o4 , "" );
69*4684ddb6SLionel Sambuc static_assert ( !(o4 == o5), "" );
70*4684ddb6SLionel Sambuc
71*4684ddb6SLionel Sambuc static_assert ( !(o5 == o1), "" );
72*4684ddb6SLionel Sambuc static_assert ( !(o5 == o2), "" );
73*4684ddb6SLionel Sambuc static_assert ( o5 == o3 , "" );
74*4684ddb6SLionel Sambuc static_assert ( !(o5 == o4), "" );
75*4684ddb6SLionel Sambuc static_assert ( o5 == o5 , "" );
76*4684ddb6SLionel Sambuc
77*4684ddb6SLionel Sambuc }
78*4684ddb6SLionel Sambuc #endif
79*4684ddb6SLionel Sambuc }
80