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
13 // constexpr const T& optional<T>::value() const;
15 #include <experimental/optional>
16 #include <type_traits>
19 #include "test_macros.h"
21 using std::experimental::optional;
22 using std::experimental::in_place_t;
23 using std::experimental::in_place;
24 using std::experimental::bad_optional_access;
30 constexpr int test() const {return 3;}
31 int test() {return 4;}
37 constexpr optional<X> opt(in_place);
38 static_assert(opt.value().test() == 3, "");
41 const optional<X> opt(in_place);
42 assert(opt.value().test() == 3);
44 #ifndef TEST_HAS_NO_EXCEPTIONS
46 const optional<X> opt;
52 catch (const bad_optional_access&)