Howard Hinnant | e7d746d | 2013-09-02 20:30:37 +0000 | [diff] [blame] | 1 | //===----------------------------------------------------------------------===// |
| 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 Rathnayake | 6edc12c | 2016-05-28 08:57:35 +0000 | [diff] [blame] | 10 | // UNSUPPORTED: c++98, c++03, c++11 |
Howard Hinnant | e7d746d | 2013-09-02 20:30:37 +0000 | [diff] [blame] | 11 | // <optional> |
| 12 | |
Marshall Clow | e61fba3 | 2014-12-09 14:49:17 +0000 | [diff] [blame] | 13 | // 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 Hinnant | e7d746d | 2013-09-02 20:30:37 +0000 | [diff] [blame] | 15 | |
Marshall Clow | dfdac03 | 2013-11-15 22:42:10 +0000 | [diff] [blame] | 16 | #include <experimental/optional> |
Howard Hinnant | e7d746d | 2013-09-02 20:30:37 +0000 | [diff] [blame] | 17 | |
| 18 | int main() |
| 19 | { |
Marshall Clow | c8528b5 | 2014-10-18 11:03:33 +0000 | [diff] [blame] | 20 | using std::experimental::optional; |
| 21 | using std::experimental::nullopt_t; |
| 22 | using std::experimental::nullopt; |
Marshall Clow | e61fba3 | 2014-12-09 14:49:17 +0000 | [diff] [blame] | 23 | |
Howard Hinnant | e7d746d | 2013-09-02 20:30:37 +0000 | [diff] [blame] | 24 | { |
| 25 | typedef int T; |
Marshall Clow | dfdac03 | 2013-11-15 22:42:10 +0000 | [diff] [blame] | 26 | typedef optional<T> O; |
Eric Fiselier | d04c685 | 2016-06-01 21:35:39 +0000 | [diff] [blame] | 27 | |
Howard Hinnant | e7d746d | 2013-09-02 20:30:37 +0000 | [diff] [blame] | 28 | constexpr O o1; // disengaged |
| 29 | constexpr O o2{1}; // engaged |
| 30 | |
Marshall Clow | e61fba3 | 2014-12-09 14:49:17 +0000 | [diff] [blame] | 31 | static_assert ( !(nullopt > o1), "" ); |
| 32 | static_assert ( !(nullopt > o2), "" ); |
| 33 | static_assert ( !(o1 > nullopt), "" ); |
| 34 | static_assert ( (o2 > nullopt), "" ); |
Howard Hinnant | e7d746d | 2013-09-02 20:30:37 +0000 | [diff] [blame] | 35 | |
Marshall Clow | e61fba3 | 2014-12-09 14:49:17 +0000 | [diff] [blame] | 36 | static_assert (noexcept(nullopt > o1), ""); |
| 37 | static_assert (noexcept(o1 > nullopt), ""); |
Howard Hinnant | e7d746d | 2013-09-02 20:30:37 +0000 | [diff] [blame] | 38 | } |
Howard Hinnant | e7d746d | 2013-09-02 20:30:37 +0000 | [diff] [blame] | 39 | } |