| //===----------------------------------------------------------------------===// |
| // The LLVM Compiler Infrastructure |
| // This file is dual licensed under the MIT and the University of Illinois Open |
| // Source Licenses. See LICENSE.TXT for details. |
| //===----------------------------------------------------------------------===// |
| // UNSUPPORTED: c++98, c++03, c++11, c++14 |
| // constexpr T& optional<T>::value() &; |
| using std::bad_optional_access; |
| constexpr int test() const & {return 3;} |
| constexpr int test() const && {return 5;} |
| int test() && {return 6;} |
| constexpr int test() & {return 7;} |
| return opt.value().test(); |
| optional<X> opt; ((void)opt); |
| ASSERT_NOT_NOEXCEPT(opt.value()); |
| ASSERT_SAME_TYPE(decltype(opt.value()), X&); |
| assert(opt.value().test() == 4); |
| #ifndef TEST_HAS_NO_EXCEPTIONS |
| catch (const bad_optional_access&) |
| static_assert(test() == 7, ""); |