• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 //===----------------------------------------------------------------------===//
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 
10 // UNSUPPORTED: c++98, c++03, c++11
11 // <optional>
12 
13 // constexpr T* optional<T>::operator->();
14 
15 #ifdef _LIBCPP_DEBUG
16 #define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
17 #endif
18 
19 #include <experimental/optional>
20 #include <type_traits>
21 #include <cassert>
22 
23 using std::experimental::optional;
24 
25 struct X
26 {
testX27     constexpr int test() const {return 3;}
28 };
29 
main()30 int main()
31 {
32     {
33         constexpr optional<X> opt(X{});
34         static_assert(opt->test() == 3, "");
35     }
36 #ifdef _LIBCPP_DEBUG
37     {
38         optional<X> opt;
39         assert(opt->test() == 3);
40         assert(false);
41     }
42 #endif  // _LIBCPP_DEBUG
43 }
44