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; 21 assert(c.real() == 0); 22 assert(c.imag() == 0); 23 c += 1.5; 24 assert(c.real() == 1.5); 25 assert(c.imag() == 0); 26 c += 1.5; 27 assert(c.real() == 3); 28 assert(c.imag() == 0); 29 c += -1.5; 30 assert(c.real() == 1.5); 31 assert(c.imag() == 0); 32 } 33 34 int main(int, char**) 35 { 36 test<float>(); 37 test<double>(); 38 test<long double>(); 39 40 return 0; 41 } 42