The ostream operator << is currently broken for std::complex with specified field widths.
For example,
const std::complex<float> x(10, 34); std::cout << std::setfill('_') << std::setw(10) << x << std::endl;
should output
___(10,34)
for a total width of 10, but currently does:
_________(10,34)
for a total width of width-1+7 = 16.
This patch a partial reversion of c3478eff7a65d6a77b34e756eabc7176a2b422e8 (reviewed at https://reviews.llvm.org/D71214), restoring the correct behavior. Also added a test to libcxx/test/std/numerics/complex.number/complex.ops/stream_output.pass.cpp to catch this error in the future.
Tested:
$ llvm-lit libcxx/test/std/numerics/complex.number