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 // <complex> 11 12 // template<class T> 13 // bool 14 // operator!=(const T& lhs, const complex<T>& rhs); 15 16 #include <complex> 17 #include <cassert> 18 19 template <class T> 20 void 21 test_constexpr() 22 { 23 #if _LIBCPP_STD_VER > 11 24 { 25 constexpr T lhs(-2.5); 26 constexpr std::complex<T> rhs(1.5, 2.5); 27 static_assert (lhs != rhs, ""); 28 } 29 { 30 constexpr T lhs(-2.5); 31 constexpr std::complex<T> rhs(1.5, 0); 32 static_assert (lhs != rhs, ""); 33 } 34 { 35 constexpr T lhs(1.5); 36 constexpr std::complex<T> rhs(1.5, 2.5); 37 static_assert (lhs != rhs, ""); 38 } 39 { 40 constexpr T lhs(1.5); 41 constexpr std::complex<T> rhs(1.5, 0); 42 static_assert (!(lhs != rhs), ""); 43 } 44 #endif 45 } 46 47 template <class T> 48 void 49 test() 50 { 51 { 52 T lhs(-2.5); 53 std::complex<T> rhs(1.5, 2.5); 54 assert (lhs != rhs); 55 } 56 { 57 T lhs(-2.5); 58 std::complex<T> rhs(1.5, 0); 59 assert (lhs != rhs); 60 } 61 { 62 T lhs(1.5); 63 std::complex<T> rhs(1.5, 2.5); 64 assert (lhs != rhs); 65 } 66 { 67 T lhs(1.5); 68 std::complex<T> rhs(1.5, 0); 69 assert (!(lhs != rhs)); 70 } 71 72 test_constexpr<T> (); 73 } 74 75 int main() 76 { 77 test<float>(); 78 test<double>(); 79 test<long double>(); 80 // test_constexpr<int>(); 81 } 82