1 //===----------------------------------------------------------------------===//
3 // The LLVM Compiler Infrastructure
5 // This file is dual licensed under the MIT and the University of Illinois Open
6 // Source Licenses. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // UNSUPPORTED: c++98, c++03, c++11, c++14
13 // template <class T> constexpr bool operator<=(const optional<T>& x, const T& v);
14 // template <class T> constexpr bool operator<=(const T& v, const optional<T>& x);
23 constexpr X(int i) : i_(i) {}
26 constexpr bool operator<=(const X& lhs, const X& rhs) {
27 return lhs.i_ <= rhs.i_;
33 typedef optional<T> O;
36 constexpr O o1; // disengaged
37 constexpr O o2{1}; // engaged
38 constexpr O o3{val}; // engaged
40 static_assert((o1 <= T(1)), "");
41 static_assert((o2 <= T(1)), ""); // equal
42 static_assert(!(o3 <= T(1)), "");
43 static_assert((o2 <= val), "");
44 static_assert((o3 <= val), ""); // equal
45 static_assert((o3 <= T(3)), "");
47 static_assert(!(T(1) <= o1), "");
48 static_assert((T(1) <= o2), ""); // equal
49 static_assert((T(1) <= o3), "");
50 static_assert(!(val <= o2), "");
51 static_assert((val <= o3), ""); // equal
52 static_assert(!(T(3) <= o3), "");
55 using O = optional<int>;
57 static_assert(o1 <= 42l, "");
58 static_assert(!(101l <= o1), "");
61 using O = optional<const int>;
63 static_assert(o1 <= 42, "");
64 static_assert(!(101 <= o1), "");