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 //===----------------------------------------------------------------------===// 8 9 // <complex> 10 11 // complex& operator/=(const complex& rhs); 12 13 #include <complex> 14 #include <cassert> 15 16 template <class T> 17 void 18 test() 19 { 20 std::complex<T> c(-4, 7.5); 21 const std::complex<T> c2(1.5, 2.5); 22 assert(c.real() == -4); 23 assert(c.imag() == 7.5); 24 c /= c2; 25 assert(c.real() == 1.5); 26 assert(c.imag() == 2.5); 27 c /= c2; 28 assert(c.real() == 1); 29 assert(c.imag() == 0); 30 31 std::complex<T> c3; 32 33 c3 = c; 34 std::complex<int> ic (1,1); 35 c3 /= ic; 36 assert(c3.real() == 0.5); 37 assert(c3.imag() == -0.5); 38 39 c3 = c; 40 std::complex<float> fc (1,1); 41 c3 /= fc; 42 assert(c3.real() == 0.5); 43 assert(c3.imag() == -0.5); 44 45 } 46 47 int main(int, char**) 48 { 49 test<float>(); 50 test<double>(); 51 test<long double>(); 52 53 return 0; 54 } 55