equal.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// template <class T> constexpr bool operator==(const optional<T>& x, const T& v); 13// template <class T> constexpr bool operator==(const T& v, const optional<T>& x); 14 15#include <optional> 16 17int main() 18{ 19#if _LIBCPP_STD_VER > 11 20 { 21 typedef int T; 22 typedef std::optional<T> O; 23 24 constexpr T val(2); 25 constexpr O o1; // disengaged 26 constexpr O o2{1}; // engaged 27 constexpr O o3{val}; // engaged 28 29 static_assert ( !(o1 == 1), "" ); 30 static_assert ( o2 == 1, "" ); 31 static_assert ( !(o3 == 1), "" ); 32 static_assert ( o3 == 2 , "" ); 33 static_assert ( o3 == val, "" ); 34 35 static_assert ( !(1 == o1), "" ); 36 static_assert ( 1 == o2, "" ); 37 static_assert ( !(1 == o3), "" ); 38 static_assert ( 2 == o3 , "" ); 39 static_assert ( val == o3 , "" ); 40 } 41#endif 42} 43