blob: 7b42847bc3fe44ddc014c27775b33e3570a7bb2c [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
Asiri Rathnayake6edc12c2016-05-28 08:57:35 +000010// UNSUPPORTED: c++98, c++03, c++11
Howard Hinnante7d746d2013-09-02 20:30:37 +000011// <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{
Marshall Clowc8528b52014-10-18 11:03:33 +000020 using std::experimental::optional;
21 using std::experimental::nullopt_t;
22 using std::experimental::nullopt;
Marshall Clowdfdac032013-11-15 22:42:10 +000023
Howard Hinnante7d746d2013-09-02 20:30:37 +000024 {
25 typedef int T;
Marshall Clowdfdac032013-11-15 22:42:10 +000026 typedef optional<T> O;
Howard Hinnante7d746d2013-09-02 20:30:37 +000027
28 constexpr O o1; // disengaged
29 constexpr O o2{1}; // engaged
30
Marshall Clowe61fba32014-12-09 14:49:17 +000031 static_assert ( (nullopt == o1), "" );
Marshall Clowdfdac032013-11-15 22:42:10 +000032 static_assert ( !(nullopt == o2), "" );
Marshall Clowe61fba32014-12-09 14:49:17 +000033 static_assert ( (o1 == nullopt), "" );
Marshall Clowdfdac032013-11-15 22:42:10 +000034 static_assert ( !(o2 == nullopt), "" );
Howard Hinnante7d746d2013-09-02 20:30:37 +000035
Marshall Clowdfdac032013-11-15 22:42:10 +000036 static_assert (noexcept(nullopt == o1), "");
37 static_assert (noexcept(o1 == nullopt), "");
Howard Hinnante7d746d2013-09-02 20:30:37 +000038 }
Howard Hinnante7d746d2013-09-02 20:30:37 +000039}