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 optional<T>& y); 13 14#include <optional> 15#include <type_traits> 16#include <cassert> 17 18int main() 19{ 20#if _LIBCPP_STD_VER > 11 21 { 22 typedef int T; 23 typedef std::optional<T> O; 24 25 constexpr O o1; // disengaged 26 constexpr O o2; // disengaged 27 constexpr O o3{1}; // engaged 28 constexpr O o4{2}; // engaged 29 constexpr O o5{1}; // engaged 30 31 static_assert ( o1 == o1 , "" ); 32 static_assert ( o1 == o2 , "" ); 33 static_assert ( !(o1 == o3), "" ); 34 static_assert ( !(o1 == o4), "" ); 35 static_assert ( !(o1 == o5), "" ); 36 37 static_assert ( o2 == o1 , "" ); 38 static_assert ( o2 == o2 , "" ); 39 static_assert ( !(o2 == o3), "" ); 40 static_assert ( !(o2 == o4), "" ); 41 static_assert ( !(o2 == o5), "" ); 42 43 static_assert ( !(o3 == o1), "" ); 44 static_assert ( !(o3 == o2), "" ); 45 static_assert ( o3 == o3 , "" ); 46 static_assert ( !(o3 == o4), "" ); 47 static_assert ( o3 == o5 , "" ); 48 49 static_assert ( !(o4 == o1), "" ); 50 static_assert ( !(o4 == o2), "" ); 51 static_assert ( !(o4 == o3), "" ); 52 static_assert ( o4 == o4 , "" ); 53 static_assert ( !(o4 == o5), "" ); 54 55 static_assert ( !(o5 == o1), "" ); 56 static_assert ( !(o5 == o2), "" ); 57 static_assert ( o5 == o3 , "" ); 58 static_assert ( !(o5 == o4), "" ); 59 static_assert ( o5 == o5 , "" ); 60 61 } 62#endif 63} 64