basic_streambuf bug
Dietmar Kuehl
dietmar_kuehl@yahoo.com
Thu May 4 07:24:00 GMT 2000
Hi,
--- Nathan Myers <ncm@cantrip.org> wrote:
> int_type __c = this->uflow();
> if ( __c == traits_type::eof())
> break;
>
> *__s++ = traits_type::to_char_type(__c);
> ++__retval;
This is still broken: You cannot assume that 'operator==()' is the
right way to compare objects of 'int_type'. Likewise, you are supposed
to assign objects with 'traits_type::assign()':
int_type __c = this->uflow(); // fine: copy ctor is there
if (traits_type::eq_int_type(__c, traits_type::eof()))
break;
traits_type::assign(*__s++, traits_type::to_char_type(c));
++__retval;
Strict use of character traits is relatively hard because it is rather
tempting to use a short cut. I haven't created test cases identifying
these problems but I'm sure that I got it wrong in some places with my
implementation, too.
Regards,
dk
=====
< mailto:dietmar_kuehl@yahoo.com >
< http://www.dietmar-kuehl.de/ >
__________________________________________________
Do You Yahoo!?
Send instant messages & get email alerts with Yahoo! Messenger.
http://im.yahoo.com/
More information about the Libstdc++
mailing list