Fix inconsistent behavior in basic_ostream::seekp () and basic_istream::seekg ()
Howard Hinnant
hhinnant at apple.com
Tue Oct 29 08:41:14 PDT 2013
On Oct 21, 2013, at 2:29 PM, Marshall Clow <mclow.lists at gmail.com> wrote:
> Basically, each of these have two methods:
>
> basic_ostream<charT,traits>& seekp(pos_type pos);
> basic_ostream<charT,traits>& seekp(off_type off, ios_base::seekdir dir);
>
> and one sets the failure bit of the stream on failure, and the other does not.
> [ Note that the standard requires us to set the failure bit on the first call, and is silent on the second. I have opened an LWG issue to resolve this. ]
> Make the second version set the failbit, and add tests.
>
> Also, the ostream calls were lacking a sentry object.
>
> For basic_istream, there were two calls, as well:
>
> basic_istream<charT,traits>& seekg(pos_type pos);
> basic_istream<charT,traits>& seekg(off_type off, ios_base::seekdir dir);
>
> and they are both specified to set the failbit on failure, and only the first one did.
> Fix that, and add a test to be sure.
>
>
> -- Marshall
>
> Marshall Clow Idio Software <mailto:mclow.lists at gmail.com>
>
> A.D. 1517: Martin Luther nails his 95 Theses to the church door and is promptly moderated down to (-1, Flamebait).
> -- Yu Suzuki
> <stream_seek.patch>_______________________________________________
> cfe-commits mailing list
> cfe-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
This looks pretty good to me. My only complaint is:
+ if ( __s && !this->fail())
(two places in <ostream>).
The "&& !this->fail()" becomes redundant with the addition of __s. So this should be:
+ if ( __s )
Thanks!
Howard
More information about the cfe-commits
mailing list