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 | |
| 10 | |
| 11 | // <optional> |
| 12 | |
| 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; |
| 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 | { |
| 20 | #if _LIBCPP_STD_VER > 11 |
Marshall Clow | c8528b5 | 2014-10-18 11:03:33 +0000 | [diff] [blame] | 21 | using std::experimental::optional; |
| 22 | using std::experimental::nullopt_t; |
| 23 | using std::experimental::nullopt; |
Marshall Clow | dfdac03 | 2013-11-15 22:42:10 +0000 | [diff] [blame] | 24 | |
Howard Hinnant | e7d746d | 2013-09-02 20:30:37 +0000 | [diff] [blame] | 25 | { |
| 26 | typedef int T; |
Marshall Clow | dfdac03 | 2013-11-15 22:42:10 +0000 | [diff] [blame] | 27 | typedef optional<T> O; |
Howard Hinnant | e7d746d | 2013-09-02 20:30:37 +0000 | [diff] [blame] | 28 | |
| 29 | constexpr O o1; // disengaged |
| 30 | constexpr O o2{1}; // engaged |
| 31 | |
Marshall Clow | e61fba3 | 2014-12-09 14:49:17 +0000 | [diff] [blame] | 32 | static_assert ( (nullopt == o1), "" ); |
Marshall Clow | dfdac03 | 2013-11-15 22:42:10 +0000 | [diff] [blame] | 33 | static_assert ( !(nullopt == o2), "" ); |
Marshall Clow | e61fba3 | 2014-12-09 14:49:17 +0000 | [diff] [blame] | 34 | static_assert ( (o1 == nullopt), "" ); |
Marshall Clow | dfdac03 | 2013-11-15 22:42:10 +0000 | [diff] [blame] | 35 | static_assert ( !(o2 == nullopt), "" ); |
Howard Hinnant | e7d746d | 2013-09-02 20:30:37 +0000 | [diff] [blame] | 36 | |
Marshall Clow | dfdac03 | 2013-11-15 22:42:10 +0000 | [diff] [blame] | 37 | static_assert (noexcept(nullopt == o1), ""); |
| 38 | static_assert (noexcept(o1 == nullopt), ""); |
Howard Hinnant | e7d746d | 2013-09-02 20:30:37 +0000 | [diff] [blame] | 39 | } |
| 40 | #endif |
| 41 | } |