blob: 931db614425634bcfe92c1050de93f90e7053ef8 [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
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 Clowdfdac032013-11-15 22:42:10 +000016#include <experimental/optional>
Howard Hinnante7d746d2013-09-02 20:30:37 +000017
18int main()
19{
20#if _LIBCPP_STD_VER > 11
Marshall Clowc8528b52014-10-18 11:03:33 +000021 using std::experimental::optional;
22 using std::experimental::nullopt_t;
23 using std::experimental::nullopt;
Marshall Clowdfdac032013-11-15 22:42:10 +000024
Howard Hinnante7d746d2013-09-02 20:30:37 +000025 {
26 typedef int T;
Marshall Clowdfdac032013-11-15 22:42:10 +000027 typedef optional<T> O;
Howard Hinnante7d746d2013-09-02 20:30:37 +000028
29 constexpr O o1; // disengaged
30 constexpr O o2{1}; // engaged
31
Marshall Clowe61fba32014-12-09 14:49:17 +000032 static_assert ( (nullopt == o1), "" );
Marshall Clowdfdac032013-11-15 22:42:10 +000033 static_assert ( !(nullopt == o2), "" );
Marshall Clowe61fba32014-12-09 14:49:17 +000034 static_assert ( (o1 == nullopt), "" );
Marshall Clowdfdac032013-11-15 22:42:10 +000035 static_assert ( !(o2 == nullopt), "" );
Howard Hinnante7d746d2013-09-02 20:30:37 +000036
Marshall Clowdfdac032013-11-15 22:42:10 +000037 static_assert (noexcept(nullopt == o1), "");
38 static_assert (noexcept(o1 == nullopt), "");
Howard Hinnante7d746d2013-09-02 20:30:37 +000039 }
40#endif
41}