1 //===----------------------------------------------------------------------===//
3 // The LLVM Compiler Infrastructure
5 // This file is dual licensed under the MIT and the University of Illinois Open
6 // Source Licenses. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // UNSUPPORTED: c++98, c++03, c++11
14 // constexpr optional(const T& v);
16 #include <experimental/optional>
17 #include <type_traits>
20 #include "test_macros.h"
22 using std::experimental::optional;
30 friend bool operator==(const X& x, const X& y) {return x.i_ == y.i_;}
37 constexpr Y(int i) : i_(i) {}
39 friend constexpr bool operator==(const Y& x, const Y& y) {return x.i_ == y.i_;}
46 Z(const Z&) {TEST_THROW(6);}
55 constexpr optional<T> opt(t);
56 static_assert(static_cast<bool>(opt) == true, "");
57 static_assert(*opt == 5, "");
59 struct test_constexpr_ctor
62 constexpr test_constexpr_ctor(const T&) {}
69 constexpr optional<T> opt(t);
70 static_assert(static_cast<bool>(opt) == true, "");
71 static_assert(*opt == 3, "");
73 struct test_constexpr_ctor
76 constexpr test_constexpr_ctor(const T&) {}
84 assert(static_cast<bool>(opt) == true);
90 constexpr optional<T> opt(t);
91 static_assert(static_cast<bool>(opt) == true, "");
92 static_assert(*opt == 3, "");
94 struct test_constexpr_ctor
97 constexpr test_constexpr_ctor(const T&) {}
101 #ifndef TEST_HAS_NO_EXCEPTIONS