blob: 15b22005b830a2bfd6dc9dbba1bbe8bc3f28e322 [file] [log] [blame]
Howard Hinnante7d746d2013-09-02 20:30:37 +00001//===----------------------------------------------------------------------===//
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
Asiri Rathnayake6edc12c2016-05-28 08:57:35 +000010// UNSUPPORTED: c++98, c++03, c++11
Howard Hinnante7d746d2013-09-02 20:30:37 +000011// <optional>
12
Marshall Clowe61fba32014-12-09 14:49:17 +000013// template <class T> constexpr bool operator>(const optional<T>& x, nullopt_t) noexcept;
14// template <class T> constexpr bool operator>(nullopt_t, const optional<T>& x) noexcept;
Howard Hinnante7d746d2013-09-02 20:30:37 +000015
Marshall Clowdfdac032013-11-15 22:42:10 +000016#include <experimental/optional>
Howard Hinnante7d746d2013-09-02 20:30:37 +000017
18int main()
19{
Marshall Clowc8528b52014-10-18 11:03:33 +000020 using std::experimental::optional;
21 using std::experimental::nullopt_t;
22 using std::experimental::nullopt;
Marshall Clowe61fba32014-12-09 14:49:17 +000023
Howard Hinnante7d746d2013-09-02 20:30:37 +000024 {
25 typedef int T;
Marshall Clowdfdac032013-11-15 22:42:10 +000026 typedef optional<T> O;
Eric Fiselierd04c6852016-06-01 21:35:39 +000027
Howard Hinnante7d746d2013-09-02 20:30:37 +000028 constexpr O o1; // disengaged
29 constexpr O o2{1}; // engaged
30
Marshall Clowe61fba32014-12-09 14:49:17 +000031 static_assert ( !(nullopt > o1), "" );
32 static_assert ( !(nullopt > o2), "" );
33 static_assert ( !(o1 > nullopt), "" );
34 static_assert ( (o2 > nullopt), "" );
Howard Hinnante7d746d2013-09-02 20:30:37 +000035
Marshall Clowe61fba32014-12-09 14:49:17 +000036 static_assert (noexcept(nullopt > o1), "");
37 static_assert (noexcept(o1 > nullopt), "");
Howard Hinnante7d746d2013-09-02 20:30:37 +000038 }
Howard Hinnante7d746d2013-09-02 20:30:37 +000039}