[RISCV] Fix mgather -> riscv.masked.strided.load combine not extending indices (...
[llvm-project.git] / libcxx / test / std / numerics / complex.number / complex.member.ops / minus_equal_complex.pass.cpp
blobc801a700e05aeaf669ba2b5f578301c1c9fe7a52
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-exception
6 //
7 //===----------------------------------------------------------------------===//
9 // <complex>
11 // complex& operator-=(const complex& rhs); // constexpr in C++20
13 #include <complex>
14 #include <cassert>
16 #include "test_macros.h"
18 template <class T>
19 TEST_CONSTEXPR_CXX20
20 bool
21 test()
23 std::complex<T> c;
24 const std::complex<T> c2(1.5, 2.5);
25 assert(c.real() == 0);
26 assert(c.imag() == 0);
27 c -= c2;
28 assert(c.real() == -1.5);
29 assert(c.imag() == -2.5);
30 c -= c2;
31 assert(c.real() == -3);
32 assert(c.imag() == -5);
34 std::complex<T> c3;
36 c3 = c;
37 std::complex<int> ic (1,1);
38 c3 -= ic;
39 assert(c3.real() == -4);
40 assert(c3.imag() == -6);
42 c3 = c;
43 std::complex<float> fc (1,1);
44 c3 -= fc;
45 assert(c3.real() == -4);
46 assert(c3.imag() == -6);
47 return true;
50 int main(int, char**)
52 test<float>();
53 test<double>();
54 test<long double>();
56 #if TEST_STD_VER >= 20
57 static_assert(test<float>());
58 static_assert(test<double>());
59 static_assert(test<long double>());
60 #endif
62 return 0;