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 // <optional> 11 12 // constexpr T* optional<T>::operator->(); 13 14 #ifdef _LIBCPP_DEBUG 15 #define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0)) 16 #endif 17 18 #include <experimental/optional> 19 #include <type_traits> 20 #include <cassert> 21 22 #if _LIBCPP_STD_VER > 11 23 24 using std::experimental::optional; 25 26 struct X 27 { testX28 constexpr int test() const {return 3;} 29 }; 30 31 #endif // _LIBCPP_STD_VER > 11 32 main()33int main() 34 { 35 #if _LIBCPP_STD_VER > 11 36 { 37 constexpr optional<X> opt(X{}); 38 static_assert(opt->test() == 3, ""); 39 } 40 #ifdef _LIBCPP_DEBUG 41 { 42 optional<X> opt; 43 assert(opt->test() == 3); 44 assert(false); 45 } 46 #endif // _LIBCPP_DEBUG 47 #endif // _LIBCPP_STD_VER > 11 48 } 49