Eric Fiselier | a9e6596 | 2016-10-12 07:46:20 +0000 | [diff] [blame] | 1 | //===----------------------------------------------------------------------===// |
| 2 | // |
Chandler Carruth | 57b08b0 | 2019-01-19 10:56:40 +0000 | [diff] [blame] | 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 4 | // See https://llvm.org/LICENSE.txt for license information. |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
Eric Fiselier | a9e6596 | 2016-10-12 07:46:20 +0000 | [diff] [blame] | 6 | // |
| 7 | //===----------------------------------------------------------------------===// |
| 8 | |
| 9 | // UNSUPPORTED: c++98, c++03, c++11, c++14 |
| 10 | // <optional> |
| 11 | |
| 12 | // template <class T> constexpr bool operator==(const optional<T>& x, nullopt_t) noexcept; |
| 13 | // template <class T> constexpr bool operator==(nullopt_t, const optional<T>& x) noexcept; |
| 14 | |
| 15 | #include <optional> |
| 16 | |
Marshall Clow | 7fc6a55 | 2019-05-31 18:35:30 +0000 | [diff] [blame] | 17 | #include "test_macros.h" |
| 18 | |
JF Bastien | 2df59c5 | 2019-02-04 20:31:13 +0000 | [diff] [blame] | 19 | int main(int, char**) |
Eric Fiselier | a9e6596 | 2016-10-12 07:46:20 +0000 | [diff] [blame] | 20 | { |
| 21 | using std::optional; |
| 22 | using std::nullopt_t; |
| 23 | using std::nullopt; |
| 24 | |
| 25 | { |
| 26 | typedef int T; |
| 27 | typedef optional<T> O; |
| 28 | |
| 29 | constexpr O o1; // disengaged |
| 30 | constexpr O o2{1}; // engaged |
| 31 | |
| 32 | static_assert ( (nullopt == o1), "" ); |
| 33 | static_assert ( !(nullopt == o2), "" ); |
| 34 | static_assert ( (o1 == nullopt), "" ); |
| 35 | static_assert ( !(o2 == nullopt), "" ); |
| 36 | |
| 37 | static_assert (noexcept(nullopt == o1), ""); |
| 38 | static_assert (noexcept(o1 == nullopt), ""); |
| 39 | } |
JF Bastien | 2df59c5 | 2019-02-04 20:31:13 +0000 | [diff] [blame] | 40 | |
| 41 | return 0; |
Eric Fiselier | a9e6596 | 2016-10-12 07:46:20 +0000 | [diff] [blame] | 42 | } |