blob: 54fb522d8cafee791031a0af3b92090eda83c970 [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 Clowdfdac032013-11-15 22:42:10 +000032 static_assert ( nullopt == o1 , "" );
33 static_assert ( !(nullopt == o2), "" );
34 static_assert ( o1 == nullopt , "" );
35 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}