Add all the relational operators to std::experimental::optional. Also update bad_optional_access to match the Library Fundamentals draft standard. This is not all of the upcoming changes to optional, though.

llvm-svn: 223775
diff --git a/libcxx/test/utilities/optional/optional.bad_optional_access/char_pointer.pass.cpp b/libcxx/test/utilities/optional/optional.bad_optional_access/char_pointer.pass.cpp
deleted file mode 100644
index eacf34c..0000000
--- a/libcxx/test/utilities/optional/optional.bad_optional_access/char_pointer.pass.cpp
+++ /dev/null
@@ -1,29 +0,0 @@
-//===----------------------------------------------------------------------===//
-//
-//                     The LLVM Compiler Infrastructure
-//
-// This file is dual licensed under the MIT and the University of Illinois Open
-// Source Licenses. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-// <optional>
-
-// class bad_optional_access;
-// explicit bad_optional_access(const char* what_arg);
-
-#include <experimental/optional>
-#include <string>
-#include <cstring>
-#include <cassert>
-
-int main()
-{
-#if _LIBCPP_STD_VER > 11
-    using std::experimental::bad_optional_access;
-
-    const char* s = "message";
-    bad_optional_access e(s);
-    assert(std::strcmp(e.what(), s) == 0);
-#endif  // _LIBCPP_STD_VER > 11
-}
diff --git a/libcxx/test/utilities/optional/optional.bad_optional_access/copy_assign.pass.cpp b/libcxx/test/utilities/optional/optional.bad_optional_access/copy_assign.pass.cpp
deleted file mode 100644
index bb78ca4..0000000
--- a/libcxx/test/utilities/optional/optional.bad_optional_access/copy_assign.pass.cpp
+++ /dev/null
@@ -1,35 +0,0 @@
-//===----------------------------------------------------------------------===//
-//
-//                     The LLVM Compiler Infrastructure
-//
-// This file is dual licensed under the MIT and the University of Illinois Open
-// Source Licenses. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-// <optional>
-
-// class bad_optional_access;
-// bad_optional_access& operator=(const bad_optional_access&);
-
-#include <experimental/optional>
-#include <string>
-#include <cstring>
-#include <type_traits>
-#include <cassert>
-
-int main()
-{
-#if _LIBCPP_STD_VER > 11
-    using std::experimental::bad_optional_access;
-
-    static_assert(std::is_nothrow_copy_assignable<bad_optional_access>::value, "");
-    const std::string s1("one message");
-    const std::string s2("another message");
-    bad_optional_access e1(s1);
-    bad_optional_access e2(s2);
-    assert(std::strcmp(e1.what(), e2.what()) != 0);
-    e1 = e2;
-    assert(std::strcmp(e1.what(), e2.what()) == 0);
-#endif  // _LIBCPP_STD_VER > 11
-}
diff --git a/libcxx/test/utilities/optional/optional.bad_optional_access/copy_ctor.pass.cpp b/libcxx/test/utilities/optional/optional.bad_optional_access/copy_ctor.pass.cpp
deleted file mode 100644
index 30ef533..0000000
--- a/libcxx/test/utilities/optional/optional.bad_optional_access/copy_ctor.pass.cpp
+++ /dev/null
@@ -1,32 +0,0 @@
-//===----------------------------------------------------------------------===//
-//
-//                     The LLVM Compiler Infrastructure
-//
-// This file is dual licensed under the MIT and the University of Illinois Open
-// Source Licenses. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-// <optional>
-
-// class bad_optional_access;
-// bad_optional_access(const bad_optional_access&);
-
-#include <experimental/optional>
-#include <string>
-#include <cstring>
-#include <type_traits>
-#include <cassert>
-
-int main()
-{
-#if _LIBCPP_STD_VER > 11
-    using std::experimental::bad_optional_access;
-
-    static_assert(std::is_nothrow_copy_constructible<bad_optional_access>::value, "");
-    const std::string s("another message");
-    bad_optional_access e1(s);
-    bad_optional_access e2 = e1;
-    assert(std::strcmp(e1.what(), e2.what()) == 0);
-#endif  // _LIBCPP_STD_VER > 11
-}
diff --git a/libcxx/test/utilities/optional/optional.bad_optional_access/default.pass.cpp b/libcxx/test/utilities/optional/optional.bad_optional_access/default.pass.cpp
index 606be40..cecf98a 100644
--- a/libcxx/test/utilities/optional/optional.bad_optional_access/default.pass.cpp
+++ b/libcxx/test/utilities/optional/optional.bad_optional_access/default.pass.cpp
@@ -9,7 +9,7 @@
 
 // <optional>
 
-// class bad_optional_access is not default constructible
+// class bad_optional_access is default constructible
 
 #include <experimental/optional>
 #include <type_traits>
@@ -18,7 +18,6 @@
 {
 #if _LIBCPP_STD_VER > 11
     using std::experimental::bad_optional_access;
-
-    static_assert(!std::is_default_constructible<bad_optional_access>::value, "");
+    bad_optional_access ex;
 #endif  // _LIBCPP_STD_VER > 11
 }
diff --git a/libcxx/test/utilities/optional/optional.bad_optional_access/string.pass.cpp b/libcxx/test/utilities/optional/optional.bad_optional_access/string.pass.cpp
deleted file mode 100644
index d0b3fb5..0000000
--- a/libcxx/test/utilities/optional/optional.bad_optional_access/string.pass.cpp
+++ /dev/null
@@ -1,29 +0,0 @@
-//===----------------------------------------------------------------------===//
-//
-//                     The LLVM Compiler Infrastructure
-//
-// This file is dual licensed under the MIT and the University of Illinois Open
-// Source Licenses. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-// <optional>
-
-// class bad_optional_access;
-// explicit bad_optional_access(const string& what_arg);
-
-#include <experimental/optional>
-#include <string>
-#include <cstring>
-#include <cassert>
-
-int main()
-{
-#if _LIBCPP_STD_VER > 11
-    using std::experimental::bad_optional_access;
-
-    const std::string s("message");
-    bad_optional_access e(s);
-    assert(std::strcmp(e.what(), s.c_str()) == 0);
-#endif  // _LIBCPP_STD_VER > 11
-}
diff --git a/libcxx/test/utilities/optional/optional.comp_with_t/equal.pass.cpp b/libcxx/test/utilities/optional/optional.comp_with_t/equal.pass.cpp
index 2380739..e796723 100644
--- a/libcxx/test/utilities/optional/optional.comp_with_t/equal.pass.cpp
+++ b/libcxx/test/utilities/optional/optional.comp_with_t/equal.pass.cpp
@@ -38,21 +38,21 @@
     typedef optional<T> O;
     
     constexpr T val(2);
-    constexpr O o1;     // disengaged
-    constexpr O o2{1};  // engaged
+    constexpr O o1;       // disengaged
+    constexpr O o2{1};    // engaged
     constexpr O o3{val};  // engaged
 
     static_assert ( !(o1 == T(1)), "" );
-    static_assert (   o2 == T(1),  "" );
+    static_assert (  (o2 == T(1)), "" );
     static_assert ( !(o3 == T(1)), "" );
-    static_assert (   o3 == T(2) , "" );
-    static_assert (   o3 == val, "" );
+    static_assert (  (o3 == T(2)), "" );
+    static_assert (  (o3 == val),  "" );
         
     static_assert ( !(T(1) == o1), "" );
-    static_assert (   T(1) == o2,  "" );
+    static_assert (  (T(1) == o2), "" );
     static_assert ( !(T(1) == o3), "" );
-    static_assert (   T(2) == o3 , "" );
-    static_assert ( val == o3 , "" );
+    static_assert (  (T(2) == o3), "" );
+    static_assert (  (val  == o3), "" );
     }
 #endif
 }
diff --git a/libcxx/test/utilities/optional/optional.comp_with_t/greater.pass.cpp b/libcxx/test/utilities/optional/optional.comp_with_t/greater.pass.cpp
new file mode 100644
index 0000000..cf3923b
--- /dev/null
+++ b/libcxx/test/utilities/optional/optional.comp_with_t/greater.pass.cpp
@@ -0,0 +1,61 @@
+//===----------------------------------------------------------------------===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <optional>
+
+// template <class T> constexpr bool operator>(const optional<T>& x, const T& v);
+// template <class T> constexpr bool operator>(const T& v, const optional<T>& x);
+
+#include <experimental/optional>
+
+#if _LIBCPP_STD_VER > 11
+
+using std::experimental::optional;
+
+struct X
+{
+    int i_;
+
+    constexpr X(int i) : i_(i) {}
+};
+
+constexpr bool operator < ( const X &lhs, const X &rhs )
+    { return lhs.i_ < rhs.i_ ; }
+    
+#endif
+
+int main()
+{
+#if _LIBCPP_STD_VER > 11
+
+    {
+    typedef X T;
+    typedef optional<T> O;
+
+    constexpr T val(2);
+    constexpr O o1;       // disengaged
+    constexpr O o2{1};    // engaged
+    constexpr O o3{val};  // engaged
+
+    static_assert ( !(o1 > T(1)), "" );
+    static_assert ( !(o2 > T(1)), "" );  // equal
+    static_assert (  (o3 > T(1)), "" );
+    static_assert ( !(o2 >  val), "" );
+    static_assert ( !(o3 >  val), "" );  // equal
+    static_assert ( !(o3 > T(3)), "" );
+
+    static_assert (   (T(1) > o1), "" );
+    static_assert (  !(T(1) > o2), "" ); // equal
+    static_assert (  !(T(1) > o3), "" );
+    static_assert (   (val  > o2), "" );
+    static_assert (  !(val  > o3), "" ); // equal
+    static_assert (   (T(3) > o3), "" );
+    }
+#endif
+}
diff --git a/libcxx/test/utilities/optional/optional.comp_with_t/greater_equal.pass.cpp b/libcxx/test/utilities/optional/optional.comp_with_t/greater_equal.pass.cpp
new file mode 100644
index 0000000..85fea13
--- /dev/null
+++ b/libcxx/test/utilities/optional/optional.comp_with_t/greater_equal.pass.cpp
@@ -0,0 +1,61 @@
+//===----------------------------------------------------------------------===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <optional>
+
+// template <class T> constexpr bool operator>=(const optional<T>& x, const T& v);
+// template <class T> constexpr bool operator>=(const T& v, const optional<T>& x);
+
+#include <experimental/optional>
+
+#if _LIBCPP_STD_VER > 11
+
+using std::experimental::optional;
+
+struct X
+{
+    int i_;
+
+    constexpr X(int i) : i_(i) {}
+};
+
+constexpr bool operator < ( const X &lhs, const X &rhs )
+    { return lhs.i_ < rhs.i_ ; }
+    
+#endif
+
+int main()
+{
+#if _LIBCPP_STD_VER > 11
+
+    {
+    typedef X T;
+    typedef optional<T> O;
+
+    constexpr T val(2);
+    constexpr O o1;       // disengaged
+    constexpr O o2{1};    // engaged
+    constexpr O o3{val};  // engaged
+
+    static_assert ( !(o1 >= T(1)), "" );
+    static_assert (  (o2 >= T(1)), "" );  // equal
+    static_assert (  (o3 >= T(1)), "" );
+    static_assert ( !(o2 >=  val), "" );
+    static_assert (  (o3 >=  val), "" );  // equal
+    static_assert ( !(o3 >= T(3)), "" );
+
+    static_assert (   (T(1) >= o1), "" );
+    static_assert (   (T(1) >= o2), "" ); // equal
+    static_assert (  !(T(1) >= o3), "" );
+    static_assert (   (val  >= o2), "" );
+    static_assert (   (val  >= o3), "" ); // equal
+    static_assert (   (T(3) >= o3), "" );
+    }
+#endif
+}
diff --git a/libcxx/test/utilities/optional/optional.comp_with_t/less_equal.pass.cpp b/libcxx/test/utilities/optional/optional.comp_with_t/less_equal.pass.cpp
new file mode 100644
index 0000000..333f7cd
--- /dev/null
+++ b/libcxx/test/utilities/optional/optional.comp_with_t/less_equal.pass.cpp
@@ -0,0 +1,61 @@
+//===----------------------------------------------------------------------===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <optional>
+
+// template <class T> constexpr bool operator<=(const optional<T>& x, const T& v);
+// template <class T> constexpr bool operator<=(const T& v, const optional<T>& x);
+
+#include <experimental/optional>
+
+#if _LIBCPP_STD_VER > 11
+
+using std::experimental::optional;
+
+struct X
+{
+    int i_;
+
+    constexpr X(int i) : i_(i) {}
+};
+
+constexpr bool operator < ( const X &lhs, const X &rhs )
+    { return lhs.i_ < rhs.i_ ; }
+    
+#endif
+
+int main()
+{
+#if _LIBCPP_STD_VER > 11
+
+    {
+    typedef X T;
+    typedef optional<T> O;
+
+    constexpr T val(2);
+    constexpr O o1;       // disengaged
+    constexpr O o2{1};    // engaged
+    constexpr O o3{val};  // engaged
+
+    static_assert (  (o1 <= T(1)), "" );
+    static_assert (  (o2 <= T(1)), "" );  // equal
+    static_assert ( !(o3 <= T(1)), "" );
+    static_assert (  (o2 <=  val), "" );
+    static_assert (  (o3 <=  val), "" );  // equal
+    static_assert (  (o3 <= T(3)), "" );
+
+    static_assert (  !(T(1) <= o1), "" );
+    static_assert (   (T(1) <= o2), "" ); // equal
+    static_assert (   (T(1) <= o3), "" );
+    static_assert (  !(val  <= o2), "" );
+    static_assert (   (val  <= o3), "" ); // equal
+    static_assert (  !(T(3) <= o3), "" );
+    }
+#endif
+}
diff --git a/libcxx/test/utilities/optional/optional.comp_with_t/less_than.pass.cpp b/libcxx/test/utilities/optional/optional.comp_with_t/less_than.pass.cpp
index 8085376..e35df21 100644
--- a/libcxx/test/utilities/optional/optional.comp_with_t/less_than.pass.cpp
+++ b/libcxx/test/utilities/optional/optional.comp_with_t/less_than.pass.cpp
@@ -37,24 +37,24 @@
     {
     typedef X T;
     typedef optional<T> O;
-    
+
     constexpr T val(2);
-    constexpr O o1;     // disengaged
-    constexpr O o2{1};  // engaged
+    constexpr O o1;       // disengaged
+    constexpr O o2{1};    // engaged
     constexpr O o3{val};  // engaged
 
-    static_assert (   o1 < T(1) , "" );
-    static_assert ( !(o2 < T(1)), "" );
+    static_assert (  (o1 < T(1)), "" );
+    static_assert ( !(o2 < T(1)), "" );  // equal
     static_assert ( !(o3 < T(1)), "" );
-    static_assert (   o2 < T(2) , "" );
-    static_assert (   o2 < T(val), "" );
-    static_assert (   o3 < T(3) , "" );
+    static_assert (  (o2 <  val), "" );
+    static_assert ( !(o3 <  val), "" );  // equal
+    static_assert (  (o3 < T(3)), "" );
 
     static_assert (  !(T(1) < o1), "" );
-    static_assert (  !(T(1) < o2), "" );
-    static_assert (    T(1) < o3 , "" );
-    static_assert (  !(T(2) < o2), "" );
-    static_assert (!(T(val) < o2), "" );
+    static_assert (  !(T(1) < o2), "" ); // equal
+    static_assert (   (T(1) < o3), "" );
+    static_assert (  !(val  < o2), "" );
+    static_assert (  !(val  < o3), "" ); // equal
     static_assert (  !(T(3) < o3), "" );
     }
 #endif
diff --git a/libcxx/test/utilities/optional/optional.comp_with_t/not_equal.pass.cpp b/libcxx/test/utilities/optional/optional.comp_with_t/not_equal.pass.cpp
new file mode 100644
index 0000000..0dad68d
--- /dev/null
+++ b/libcxx/test/utilities/optional/optional.comp_with_t/not_equal.pass.cpp
@@ -0,0 +1,58 @@
+//===----------------------------------------------------------------------===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <optional>
+
+// template <class T> constexpr bool operator!=(const optional<T>& x, const T& v);
+// template <class T> constexpr bool operator!=(const T& v, const optional<T>& x);
+
+#include <experimental/optional>
+
+#if _LIBCPP_STD_VER > 11
+
+using std::experimental::optional;
+
+struct X
+{
+    int i_;
+
+    constexpr X(int i) : i_(i) {}
+};
+
+constexpr bool operator == ( const X &lhs, const X &rhs )
+    { return lhs.i_ == rhs.i_ ; }
+    
+#endif
+
+int main()
+{
+#if _LIBCPP_STD_VER > 11
+    {
+    typedef X T;
+    typedef optional<T> O;
+    
+    constexpr T val(2);
+    constexpr O o1;       // disengaged
+    constexpr O o2{1};    // engaged
+    constexpr O o3{val};  // engaged
+
+    static_assert (  (o1 != T(1)), "" );
+    static_assert ( !(o2 != T(1)), "" );
+    static_assert (  (o3 != T(1)), "" );
+    static_assert ( !(o3 != T(2)), "" );
+    static_assert ( !(o3 != val),  "" );
+        
+    static_assert (  (T(1) != o1), "" );
+    static_assert ( !(T(1) != o2), "" );
+    static_assert (  (T(1) != o3), "" );
+    static_assert ( !(T(2) != o3), "" );
+    static_assert ( !(val  != o3), "" );
+    }
+#endif
+}
diff --git a/libcxx/test/utilities/optional/optional.nullops/eqaul.pass.cpp b/libcxx/test/utilities/optional/optional.nullops/equal.pass.cpp
similarity index 92%
rename from libcxx/test/utilities/optional/optional.nullops/eqaul.pass.cpp
rename to libcxx/test/utilities/optional/optional.nullops/equal.pass.cpp
index 54fb522..931db61 100644
--- a/libcxx/test/utilities/optional/optional.nullops/eqaul.pass.cpp
+++ b/libcxx/test/utilities/optional/optional.nullops/equal.pass.cpp
@@ -29,9 +29,9 @@
     constexpr O o1;     // disengaged
     constexpr O o2{1};  // engaged
 
-    static_assert (   nullopt == o1 , "" );
+    static_assert (  (nullopt == o1), "" );
     static_assert ( !(nullopt == o2), "" );
-    static_assert (   o1 == nullopt , "" );
+    static_assert (  (o1 == nullopt), "" );
     static_assert ( !(o2 == nullopt), "" );
 
     static_assert (noexcept(nullopt == o1), "");
diff --git a/libcxx/test/utilities/optional/optional.nullops/eqaul.pass.cpp b/libcxx/test/utilities/optional/optional.nullops/greater.pass.cpp
similarity index 60%
copy from libcxx/test/utilities/optional/optional.nullops/eqaul.pass.cpp
copy to libcxx/test/utilities/optional/optional.nullops/greater.pass.cpp
index 54fb522..b72a4d3 100644
--- a/libcxx/test/utilities/optional/optional.nullops/eqaul.pass.cpp
+++ b/libcxx/test/utilities/optional/optional.nullops/greater.pass.cpp
@@ -10,8 +10,8 @@
 
 // <optional>
 
-// template <class T> constexpr bool operator==(const optional<T>& x, nullopt_t) noexcept;
-// template <class T> constexpr bool operator==(nullopt_t, const optional<T>& x) noexcept;
+// template <class T> constexpr bool operator>(const optional<T>& x, nullopt_t) noexcept;
+// template <class T> constexpr bool operator>(nullopt_t, const optional<T>& x) noexcept;
 
 #include <experimental/optional>
 
@@ -21,7 +21,7 @@
     using std::experimental::optional;
     using std::experimental::nullopt_t;
     using std::experimental::nullopt;
-    
+
     {
     typedef int T;
     typedef optional<T> O;
@@ -29,13 +29,13 @@
     constexpr O o1;     // disengaged
     constexpr O o2{1};  // engaged
 
-    static_assert (   nullopt == o1 , "" );
-    static_assert ( !(nullopt == o2), "" );
-    static_assert (   o1 == nullopt , "" );
-    static_assert ( !(o2 == nullopt), "" );
+    static_assert ( !(nullopt > o1), "" );
+    static_assert ( !(nullopt > o2), "" );
+    static_assert ( !(o1 > nullopt), "" );
+    static_assert (  (o2 > nullopt), "" );
 
-    static_assert (noexcept(nullopt == o1), "");
-    static_assert (noexcept(o1 == nullopt), "");
+    static_assert (noexcept(nullopt > o1), "");
+    static_assert (noexcept(o1 > nullopt), "");
     }
 #endif
 }
diff --git a/libcxx/test/utilities/optional/optional.nullops/eqaul.pass.cpp b/libcxx/test/utilities/optional/optional.nullops/greater_equal.pass.cpp
similarity index 65%
copy from libcxx/test/utilities/optional/optional.nullops/eqaul.pass.cpp
copy to libcxx/test/utilities/optional/optional.nullops/greater_equal.pass.cpp
index 54fb522..86c8743 100644
--- a/libcxx/test/utilities/optional/optional.nullops/eqaul.pass.cpp
+++ b/libcxx/test/utilities/optional/optional.nullops/greater_equal.pass.cpp
@@ -10,8 +10,8 @@
 
 // <optional>
 
-// template <class T> constexpr bool operator==(const optional<T>& x, nullopt_t) noexcept;
-// template <class T> constexpr bool operator==(nullopt_t, const optional<T>& x) noexcept;
+// template <class T> constexpr bool operator>=(const optional<T>& x, nullopt_t) noexcept;
+// template <class T> constexpr bool operator>=(nullopt_t, const optional<T>& x) noexcept;
 
 #include <experimental/optional>
 
@@ -21,7 +21,7 @@
     using std::experimental::optional;
     using std::experimental::nullopt_t;
     using std::experimental::nullopt;
-    
+
     {
     typedef int T;
     typedef optional<T> O;
@@ -29,13 +29,13 @@
     constexpr O o1;     // disengaged
     constexpr O o2{1};  // engaged
 
-    static_assert (   nullopt == o1 , "" );
-    static_assert ( !(nullopt == o2), "" );
-    static_assert (   o1 == nullopt , "" );
-    static_assert ( !(o2 == nullopt), "" );
+    static_assert (  (nullopt >= o1), "" );
+    static_assert ( !(nullopt >= o2), "" );
+    static_assert (  (o1 >= nullopt), "" );
+    static_assert (  (o2 >= nullopt), "" );
 
-    static_assert (noexcept(nullopt == o1), "");
-    static_assert (noexcept(o1 == nullopt), "");
+    static_assert (noexcept(nullopt >= o1), "");
+    static_assert (noexcept(o1 >= nullopt), "");
     }
 #endif
 }
diff --git a/libcxx/test/utilities/optional/optional.nullops/eqaul.pass.cpp b/libcxx/test/utilities/optional/optional.nullops/less_equal.pass.cpp
similarity index 65%
copy from libcxx/test/utilities/optional/optional.nullops/eqaul.pass.cpp
copy to libcxx/test/utilities/optional/optional.nullops/less_equal.pass.cpp
index 54fb522..3e8444b 100644
--- a/libcxx/test/utilities/optional/optional.nullops/eqaul.pass.cpp
+++ b/libcxx/test/utilities/optional/optional.nullops/less_equal.pass.cpp
@@ -10,8 +10,8 @@
 
 // <optional>
 
-// template <class T> constexpr bool operator==(const optional<T>& x, nullopt_t) noexcept;
-// template <class T> constexpr bool operator==(nullopt_t, const optional<T>& x) noexcept;
+// template <class T> constexpr bool operator<=(const optional<T>& x, nullopt_t) noexcept;
+// template <class T> constexpr bool operator<=(nullopt_t, const optional<T>& x) noexcept;
 
 #include <experimental/optional>
 
@@ -21,7 +21,7 @@
     using std::experimental::optional;
     using std::experimental::nullopt_t;
     using std::experimental::nullopt;
-    
+
     {
     typedef int T;
     typedef optional<T> O;
@@ -29,13 +29,13 @@
     constexpr O o1;     // disengaged
     constexpr O o2{1};  // engaged
 
-    static_assert (   nullopt == o1 , "" );
-    static_assert ( !(nullopt == o2), "" );
-    static_assert (   o1 == nullopt , "" );
-    static_assert ( !(o2 == nullopt), "" );
+    static_assert (  (nullopt <= o1), "" );
+    static_assert (  (nullopt <= o2), "" );
+    static_assert (  (o1 <= nullopt), "" );
+    static_assert ( !(o2 <= nullopt), "" );
 
-    static_assert (noexcept(nullopt == o1), "");
-    static_assert (noexcept(o1 == nullopt), "");
+    static_assert (noexcept(nullopt <= o1), "");
+    static_assert (noexcept(o1 <= nullopt), "");
     }
 #endif
 }
diff --git a/libcxx/test/utilities/optional/optional.nullops/less_than.pass.cpp b/libcxx/test/utilities/optional/optional.nullops/less_than.pass.cpp
index 576a98a..149c809 100644
--- a/libcxx/test/utilities/optional/optional.nullops/less_than.pass.cpp
+++ b/libcxx/test/utilities/optional/optional.nullops/less_than.pass.cpp
@@ -30,7 +30,7 @@
     constexpr O o2{1};  // engaged
 
     static_assert ( !(nullopt < o1), "" );
-    static_assert (   nullopt < o2 , "" );
+    static_assert (  (nullopt < o2), "" );
     static_assert ( !(o1 < nullopt), "" );
     static_assert ( !(o2 < nullopt), "" );
 
diff --git a/libcxx/test/utilities/optional/optional.nullops/eqaul.pass.cpp b/libcxx/test/utilities/optional/optional.nullops/not_equal.pass.cpp
similarity index 65%
copy from libcxx/test/utilities/optional/optional.nullops/eqaul.pass.cpp
copy to libcxx/test/utilities/optional/optional.nullops/not_equal.pass.cpp
index 54fb522..6f28edf 100644
--- a/libcxx/test/utilities/optional/optional.nullops/eqaul.pass.cpp
+++ b/libcxx/test/utilities/optional/optional.nullops/not_equal.pass.cpp
@@ -10,8 +10,8 @@
 
 // <optional>
 
-// template <class T> constexpr bool operator==(const optional<T>& x, nullopt_t) noexcept;
-// template <class T> constexpr bool operator==(nullopt_t, const optional<T>& x) noexcept;
+// template <class T> constexpr bool operator!=(const optional<T>& x, nullopt_t) noexcept;
+// template <class T> constexpr bool operator!=(nullopt_t, const optional<T>& x) noexcept;
 
 #include <experimental/optional>
 
@@ -29,13 +29,13 @@
     constexpr O o1;     // disengaged
     constexpr O o2{1};  // engaged
 
-    static_assert (   nullopt == o1 , "" );
-    static_assert ( !(nullopt == o2), "" );
-    static_assert (   o1 == nullopt , "" );
-    static_assert ( !(o2 == nullopt), "" );
+    static_assert ( !(nullopt != o1), "" );
+    static_assert (  (nullopt != o2), "" );
+    static_assert ( !(o1 != nullopt), "" );
+    static_assert (  (o2 != nullopt), "" );
 
-    static_assert (noexcept(nullopt == o1), "");
-    static_assert (noexcept(o1 == nullopt), "");
+    static_assert (noexcept(nullopt != o1), "");
+    static_assert (noexcept(o1 != nullopt), "");
     }
 #endif
 }
diff --git a/libcxx/test/utilities/optional/optional.relops/greater_equal.pass.cpp b/libcxx/test/utilities/optional/optional.relops/greater_equal.pass.cpp
new file mode 100644
index 0000000..98d6855
--- /dev/null
+++ b/libcxx/test/utilities/optional/optional.relops/greater_equal.pass.cpp
@@ -0,0 +1,75 @@
+//===----------------------------------------------------------------------===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <optional>
+
+// template <class T> constexpr bool operator>= (const optional<T>& x, const optional<T>& y);
+
+#include <experimental/optional>
+
+#if _LIBCPP_STD_VER > 11
+
+using std::experimental::optional;
+
+struct X
+{
+    int i_;
+
+    constexpr X(int i) : i_(i) {}
+};
+
+constexpr bool operator < ( const X &lhs, const X &rhs )
+    { return lhs.i_ < rhs.i_ ; }
+
+#endif
+
+int main()
+{
+#if _LIBCPP_STD_VER > 11
+    {
+    typedef optional<X> O;
+    
+    constexpr O o1;     // disengaged
+    constexpr O o2;     // disengaged
+    constexpr O o3{1};  // engaged
+    constexpr O o4{2};  // engaged
+    constexpr O o5{1};  // engaged
+    
+    static_assert (  (o1 >= o1), "" );
+    static_assert (  (o1 >= o2), "" );
+    static_assert ( !(o1 >= o3), "" );
+    static_assert ( !(o1 >= o4), "" );
+    static_assert ( !(o1 >= o5), "" );
+
+    static_assert (  (o2 >= o1), "" );
+    static_assert (  (o2 >= o2), "" );
+    static_assert ( !(o2 >= o3), "" );
+    static_assert ( !(o2 >= o4), "" );
+    static_assert ( !(o2 >= o5), "" );
+
+    static_assert (  (o3 >= o1), "" );
+    static_assert (  (o3 >= o2), "" );
+    static_assert (  (o3 >= o3), "" );
+    static_assert ( !(o3 >= o4), "" );
+    static_assert (  (o3 >= o5), "" );
+
+    static_assert (  (o4 >= o1), "" );
+    static_assert (  (o4 >= o2), "" );
+    static_assert (  (o4 >= o3), "" );
+    static_assert (  (o4 >= o4), "" );
+    static_assert (  (o4 >= o5), "" );
+
+    static_assert (  (o5 >= o1), "" );
+    static_assert (  (o5 >= o2), "" );
+    static_assert (  (o5 >= o3), "" );
+    static_assert ( !(o5 >= o4), "" );
+    static_assert (  (o5 >= o5), "" );
+    }
+#endif
+}
diff --git a/libcxx/test/utilities/optional/optional.relops/greater_than.pass.cpp b/libcxx/test/utilities/optional/optional.relops/greater_than.pass.cpp
new file mode 100644
index 0000000..d51bd4f
--- /dev/null
+++ b/libcxx/test/utilities/optional/optional.relops/greater_than.pass.cpp
@@ -0,0 +1,75 @@
+//===----------------------------------------------------------------------===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <optional>
+
+// template <class T> constexpr bool operator> (const optional<T>& x, const optional<T>& y);
+
+#include <experimental/optional>
+
+#if _LIBCPP_STD_VER > 11
+
+using std::experimental::optional;
+
+struct X
+{
+    int i_;
+
+    constexpr X(int i) : i_(i) {}
+};
+
+constexpr bool operator < ( const X &lhs, const X &rhs )
+    { return lhs.i_ < rhs.i_ ; }
+
+#endif
+
+int main()
+{
+#if _LIBCPP_STD_VER > 11
+    {
+    typedef optional<X> O;
+    
+    constexpr O o1;     // disengaged
+    constexpr O o2;     // disengaged
+    constexpr O o3{1};  // engaged
+    constexpr O o4{2};  // engaged
+    constexpr O o5{1};  // engaged
+    
+    static_assert ( !(o1 > o1), "" );
+    static_assert ( !(o1 > o2), "" );
+    static_assert ( !(o1 > o3), "" );
+    static_assert ( !(o1 > o4), "" );
+    static_assert ( !(o1 > o5), "" );
+
+    static_assert ( !(o2 > o1), "" );
+    static_assert ( !(o2 > o2), "" );
+    static_assert ( !(o2 > o3), "" );
+    static_assert ( !(o2 > o4), "" );
+    static_assert ( !(o2 > o5), "" );
+
+    static_assert (  (o3 > o1), "" );
+    static_assert (  (o3 > o2), "" );
+    static_assert ( !(o3 > o3), "" );
+    static_assert ( !(o3 > o4), "" );
+    static_assert ( !(o3 > o5), "" );
+
+    static_assert (  (o4 > o1), "" );
+    static_assert (  (o4 > o2), "" );
+    static_assert (  (o4 > o3), "" );
+    static_assert ( !(o4 > o4), "" );
+    static_assert (  (o4 > o5), "" );
+
+    static_assert (  (o5 > o1), "" );
+    static_assert (  (o5 > o2), "" );
+    static_assert ( !(o5 > o3), "" );
+    static_assert ( !(o5 > o4), "" );
+    static_assert ( !(o5 > o5), "" );
+    }
+#endif
+}
diff --git a/libcxx/test/utilities/optional/optional.relops/less_equal.pass.cpp b/libcxx/test/utilities/optional/optional.relops/less_equal.pass.cpp
new file mode 100644
index 0000000..326f3a8
--- /dev/null
+++ b/libcxx/test/utilities/optional/optional.relops/less_equal.pass.cpp
@@ -0,0 +1,75 @@
+//===----------------------------------------------------------------------===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <optional>
+
+// template <class T> constexpr bool operator<= (const optional<T>& x, const optional<T>& y);
+
+#include <experimental/optional>
+
+#if _LIBCPP_STD_VER > 11
+
+using std::experimental::optional;
+
+struct X
+{
+    int i_;
+
+    constexpr X(int i) : i_(i) {}
+};
+
+constexpr bool operator < ( const X &lhs, const X &rhs )
+    { return lhs.i_ < rhs.i_ ; }
+
+#endif
+
+int main()
+{
+#if _LIBCPP_STD_VER > 11
+    {
+    typedef optional<X> O;
+    
+    constexpr O o1;     // disengaged
+    constexpr O o2;     // disengaged
+    constexpr O o3{1};  // engaged
+    constexpr O o4{2};  // engaged
+    constexpr O o5{1};  // engaged
+    
+    static_assert (  (o1 <= o1), "" );
+    static_assert (  (o1 <= o2), "" );
+    static_assert (  (o1 <= o3), "" );
+    static_assert (  (o1 <= o4), "" );
+    static_assert (  (o1 <= o5), "" );
+
+    static_assert (  (o2 <= o1), "" );
+    static_assert (  (o2 <= o2), "" );
+    static_assert (  (o2 <= o3), "" );
+    static_assert (  (o2 <= o4), "" );
+    static_assert (  (o2 <= o5), "" );
+
+    static_assert ( !(o3 <= o1), "" );
+    static_assert ( !(o3 <= o2), "" );
+    static_assert (  (o3 <= o3), "" );
+    static_assert (  (o3 <= o4), "" );
+    static_assert (  (o3 <= o5), "" );
+
+    static_assert ( !(o4 <= o1), "" );
+    static_assert ( !(o4 <= o2), "" );
+    static_assert ( !(o4 <= o3), "" );
+    static_assert (  (o4 <= o4), "" );
+    static_assert ( !(o4 <= o5), "" );
+
+    static_assert ( !(o5 <= o1), "" );
+    static_assert ( !(o5 <= o2), "" );
+    static_assert (  (o5 <= o3), "" );
+    static_assert (  (o5 <= o4), "" );
+    static_assert (  (o5 <= o5), "" );
+    }
+#endif
+}
diff --git a/libcxx/test/utilities/optional/optional.relops/less_than.pass.cpp b/libcxx/test/utilities/optional/optional.relops/less_than.pass.cpp
index 8d70e92..37f7e19 100644
--- a/libcxx/test/utilities/optional/optional.relops/less_than.pass.cpp
+++ b/libcxx/test/utilities/optional/optional.relops/less_than.pass.cpp
@@ -43,20 +43,20 @@
     
     static_assert ( !(o1 < o1), "" );
     static_assert ( !(o1 < o2), "" );
-    static_assert (   o1 < o3 , "" );
-    static_assert (   o1 < o4 , "" );
-    static_assert (   o1 < o5 , "" );
+    static_assert (  (o1 < o3), "" );
+    static_assert (  (o1 < o4), "" );
+    static_assert (  (o1 < o5), "" );
 
     static_assert ( !(o2 < o1), "" );
     static_assert ( !(o2 < o2), "" );
-    static_assert (   o2 < o3 , "" );
-    static_assert (   o2 < o4 , "" );
-    static_assert (   o2 < o5 , "" );
+    static_assert (  (o2 < o3), "" );
+    static_assert (  (o2 < o4), "" );
+    static_assert (  (o2 < o5), "" );
 
     static_assert ( !(o3 < o1), "" );
     static_assert ( !(o3 < o2), "" );
     static_assert ( !(o3 < o3), "" );
-    static_assert (   o3 < o4 , "" );
+    static_assert (  (o3 < o4), "" );
     static_assert ( !(o3 < o5), "" );
 
     static_assert ( !(o4 < o1), "" );
@@ -68,7 +68,7 @@
     static_assert ( !(o5 < o1), "" );
     static_assert ( !(o5 < o2), "" );
     static_assert ( !(o5 < o3), "" );
-    static_assert (   o5 < o4 , "" );
+    static_assert (  (o5 < o4), "" );
     static_assert ( !(o5 < o5), "" );
     }
 #endif
diff --git a/libcxx/test/utilities/optional/optional.relops/not_equal.pass.cpp b/libcxx/test/utilities/optional/optional.relops/not_equal.pass.cpp
new file mode 100644
index 0000000..f386c7e
--- /dev/null
+++ b/libcxx/test/utilities/optional/optional.relops/not_equal.pass.cpp
@@ -0,0 +1,79 @@
+//===----------------------------------------------------------------------===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <optional>
+
+// template <class T> constexpr bool operator!=(const optional<T>& x, const optional<T>& y);
+
+#include <experimental/optional>
+#include <type_traits>
+#include <cassert>
+
+#if _LIBCPP_STD_VER > 11
+
+using std::experimental::optional;
+
+struct X
+{
+    int i_;
+
+    constexpr X(int i) : i_(i) {}
+};
+
+constexpr bool operator == ( const X &lhs, const X &rhs )
+    { return lhs.i_ == rhs.i_ ; }
+    
+#endif
+
+int main()
+{
+#if _LIBCPP_STD_VER > 11
+    {
+    typedef X T;
+    typedef optional<T> O;
+    
+    constexpr O o1;     // disengaged
+    constexpr O o2;     // disengaged
+    constexpr O o3{1};  // engaged
+    constexpr O o4{2};  // engaged
+    constexpr O o5{1};  // engaged
+
+    static_assert ( !(o1 != o1), "" );
+    static_assert ( !(o1 != o2), "" );
+    static_assert (  (o1 != o3), "" );
+    static_assert (  (o1 != o4), "" );
+    static_assert (  (o1 != o5), "" );
+
+    static_assert ( !(o2 != o1), "" );
+    static_assert ( !(o2 != o2), "" );
+    static_assert (  (o2 != o3), "" );
+    static_assert (  (o2 != o4), "" );
+    static_assert (  (o2 != o5), "" );
+
+    static_assert (  (o3 != o1), "" );
+    static_assert (  (o3 != o2), "" );
+    static_assert ( !(o3 != o3), "" );
+    static_assert (  (o3 != o4), "" );
+    static_assert ( !(o3 != o5), "" );
+
+    static_assert (  (o4 != o1), "" );
+    static_assert (  (o4 != o2), "" );
+    static_assert (  (o4 != o3), "" );
+    static_assert ( !(o4 != o4), "" );
+    static_assert (  (o4 != o5), "" );
+
+    static_assert (  (o5 != o1), "" );
+    static_assert (  (o5 != o2), "" );
+    static_assert ( !(o5 != o3), "" );
+    static_assert (  (o5 != o4), "" );
+    static_assert ( !(o5 != o5), "" );
+
+    }
+#endif
+}