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 // 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 int test() const {return 2;} testX29 int test() {return 3;} 30 }; 31 32 #endif // _LIBCPP_STD_VER > 11 33 main()34int main() 35 { 36 #if _LIBCPP_STD_VER > 11 37 { 38 optional<X> opt(X{}); 39 assert(opt->test() == 3); 40 } 41 #ifdef _LIBCPP_DEBUG 42 { 43 optional<X> opt; 44 assert(opt->test() == 3); 45 assert(false); 46 } 47 #endif // _LIBCPP_DEBUG 48 #endif // _LIBCPP_STD_VER > 11 49 } 50