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 | |
| 16 | #include <optional> |
| 17 | |
| 18 | int main() |
| 19 | { |
| 20 | #if _LIBCPP_STD_VER > 11 |
| 21 | { |
| 22 | typedef int T; |
| 23 | typedef std::optional<T> O; |
| 24 | |
| 25 | constexpr O o1; // disengaged |
| 26 | constexpr O o2{1}; // engaged |
| 27 | |
| 28 | static_assert ( std::nullopt == o1 , "" ); |
| 29 | static_assert ( !(std::nullopt == o2), "" ); |
| 30 | static_assert ( o1 == std::nullopt , "" ); |
| 31 | static_assert ( !(o2 == std::nullopt), "" ); |
| 32 | |
| 33 | static_assert (noexcept(std::nullopt == o1), ""); |
| 34 | static_assert (noexcept(o1 == std::nullopt), ""); |
| 35 | } |
| 36 | #endif |
| 37 | } |