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 T& rhs); 12 13 #include <complex> 14 #include <cassert> 15 16 template <class T> 17 void 18 test() 19 { 20 std::complex<T> c(1); 21 assert(c.real() == 1); 22 assert(c.imag() == 0); 23 c /= 0.5; 24 assert(c.real() == 2); 25 assert(c.imag() == 0); 26 c /= 0.5; 27 assert(c.real() == 4); 28 assert(c.imag() == 0); 29 c /= -0.5; 30 assert(c.real() == -8); 31 assert(c.imag() == 0); 32 c.imag(2); 33 c /= 0.5; 34 assert(c.real() == -16); 35 assert(c.imag() == 4); 36 } 37 38 int main(int, char**) 39 { 40 test<float>(); 41 test<double>(); 42 test<long double>(); 43 44 return 0; 45 } 46