op_arrow.pass.cpp revision 01afa5c6e407e985d9643707d7b7ab1384bd9317
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 <optional> 19#include <type_traits> 20#include <cassert> 21 22#if _LIBCPP_STD_VER > 11 23 24struct X 25{ 26 int test() const {return 2;} 27 int test() {return 3;} 28}; 29 30#endif // _LIBCPP_STD_VER > 11 31 32int main() 33{ 34#if _LIBCPP_STD_VER > 11 35 { 36 std::optional<X> opt(X{}); 37 assert(opt->test() == 3); 38 } 39#ifdef _LIBCPP_DEBUG 40 { 41 std::optional<X> opt; 42 assert(opt->test() == 3); 43 assert(false); 44 } 45#endif // _LIBCPP_DEBUG 46#endif // _LIBCPP_STD_VER > 11 47} 48