73 lines · cpp
1//===----------------------------------------------------------------------===//2//3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.4// See https://llvm.org/LICENSE.txt for license information.5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception6//7//===----------------------------------------------------------------------===//8 9// <complex>10 11// template<class T>12// bool13// operator!=(const complex<T>& lhs, const complex<T>& rhs);14 15#include <complex>16#include <cassert>17 18#include "test_macros.h"19 20template <class T>21TEST_CONSTEXPR_CXX2022void23test_constexpr()24{25#if TEST_STD_VER > 1126 {27 constexpr std::complex<T> lhs(1.5, 2.5);28 constexpr std::complex<T> rhs(1.5, -2.5);29 static_assert(lhs != rhs, "");30 }31 {32 constexpr std::complex<T> lhs(1.5, 2.5);33 constexpr std::complex<T> rhs(1.5, 2.5);34 static_assert(!(lhs != rhs), "" );35 }36#endif37}38 39template <class T>40TEST_CONSTEXPR_CXX2041bool42test()43{44 {45 const std::complex<T> lhs(1.5, 2.5);46 const std::complex<T> rhs(1.5, -2.5);47 assert(lhs != rhs);48 }49 {50 const std::complex<T> lhs(1.5, 2.5);51 const std::complex<T> rhs(1.5, 2.5);52 assert(!(lhs != rhs));53 }54 55 test_constexpr<T> ();56 return true;57}58 59int main(int, char**)60{61 test<float>();62 test<double>();63 test<long double>();64 65#if TEST_STD_VER > 1766 static_assert(test<float>());67 static_assert(test<double>());68 static_assert(test<long double>());69#endif70 71 return 0;72}73