On 08/10/14 10:32, YongHao Hu wrote:
dlls/msvcp90/ios.c | 28 ++++++++++++++++++++++++++++ dlls/msvcp90/msvcp90.spec | 4 ++-- 2 files changed, 30 insertions(+), 2 deletions(-)
This implementation is not behaving well in following case: complex<float> c = complex<float>(3.1, -0.5); cout.width(20); cout << c << endl; The width should affect whole complex value instead of first float.
Cheers, Piotr
I tried to fix this problem and and the result is below. - basic_streambuf_char_sputc(base->strbuf, '('); +// basic_streambuf_char_sputc(base->strbuf, '('); + basic_ostream_char_print_ch(ostr, '('); After this change, the problem is solve. And other cout format like setw() and setfill() tests are normal. However, I am considering an issue now. +// basic_ostream_char_print_double(ostr, val->real); num_put_char_put_double(numput, &dest, dest, &base->base, basic_ios_char_fill_get(base), val->real); + // basic_ostream_char_print_ch(ostr, ','); basic_streambuf_char_sputc(base->strbuf, ','); + // basic_ostream_char_print_double(ostr, val->imag); num_put_char_put_double(numput, &dest, dest, &base->base, basic_ios_char_fill_get(base), val->imag); + // basic_ostream_char_print_ch(ostr, ')'); basic_streambuf_char_sputc(base->strbuf, ')');
I thought the difference between basic_ostream_char_print_xxx and num_put_char_put_xx is that the former create and destroy sentry. There is no doubt that it will decrease the efficency. On the other hand, my fix seems not so right. Could you please give me some advice? Thank you.
On Thursday, August 14, 2014 09:09 PM, Piotr Caban wrote:
On 08/10/14 10:32, YongHao Hu wrote:
dlls/msvcp90/ios.c | 28 ++++++++++++++++++++++++++++ dlls/msvcp90/msvcp90.spec | 4 ++-- 2 files changed, 30 insertions(+), 2 deletions(-)
This implementation is not behaving well in following case: complex<float> c = complex<float>(3.1, -0.5); cout.width(20); cout << c << endl; The width should affect whole complex value instead of first float.
Cheers, Piotr
On 08/15/14 12:18, YongHao Hu wrote:
I tried to fix this problem and and the result is below.
basic_streambuf_char_sputc(base->strbuf, '(');
+// basic_streambuf_char_sputc(base->strbuf, '(');
basic_ostream_char_print_ch(ostr, '(');
After this change, the problem is solve. And other cout format like setw() and setfill() tests are normal. However, I am considering an issue now. +// basic_ostream_char_print_double(ostr, val->real); num_put_char_put_double(numput, &dest, dest, &base->base, basic_ios_char_fill_get(base), val->real);
- // basic_ostream_char_print_ch(ostr, ','); basic_streambuf_char_sputc(base->strbuf, ',');
- // basic_ostream_char_print_double(ostr, val->imag); num_put_char_put_double(numput, &dest, dest, &base->base,
basic_ios_char_fill_get(base), val->imag);
- // basic_ostream_char_print_ch(ostr, ')'); basic_streambuf_char_sputc(base->strbuf, ')');
I thought the difference between basic_ostream_char_print_xxx and num_put_char_put_xx is that the former create and destroy sentry. There is no doubt that it will decrease the efficency. On the other hand, my fix seems not so right. Could you please give me some advice?
This code is still not working well with the test I've sent. The width should affect whole complex value, not only the first character (it will be easier to see it if you set width to 5, in this case your implementation will add 4 spaces, native will add 0 spaces).
Probably the easiest way to implement it is to write whole complex to temporary ostringstream and print it using basic_ostream_char_print_str.
Cheers, Piotr