1 //===----------------------------------------------------------------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 
9 // UNSUPPORTED: c++03, c++11, c++14
10 // <optional>
11 
12 // constexpr T* optional<T>::operator->();
13 
14 // UNSUPPORTED: libcxx-no-debug-mode
15 
16 // ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1
17 #define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
18 
19 #include <optional>
20 #include <cassert>
21 
22 #include "test_macros.h"
23 
24 struct X {
testX25     int test() noexcept {return 3;}
26 };
27 
main(int,char **)28 int main(int, char**) {
29     std::optional<X> opt;
30     assert(opt->test() == 3);
31     assert(false);
32 
33     return 0;
34 }
35