Created on 1999-03-06.00:00:00 last changed 172 months ago
[ Post-Tokyo: Matt Austern comments:
Is it a problem with basic_istream and basic_ostream, or is it a problem
with basic_stringbuf?
We could resolve the issue either by changing basic_istream and
basic_ostream, or by changing basic_stringbuf. I prefer the latter
change (or maybe both changes): I don't see any reason for the standard to
require that std::stringbuf s(std::string("foo"), std::ios_base::in);
s.pubseekoff(0, std::ios_base::beg); must fail.
This requirement is a bit weird. There's no similar requirement
for basic_streambuf<>::seekpos, or for basic_filebuf<>::seekoff or
basic_filebuf<>::seekpos. ]
[ Tokyo: Reviewed by the LWG. PJP noted that although his docs are incorrect, his implementation already implements the Proposed Resolution. ]
[ Dublin: Dietmar Kühl thinks this is probably correct, but would like the opinion of more iostream experts before taking action. ]
Proposed resolution:
In section 27.6.1.3 change:
basic_istream<charT,traits>& seekg(pos_type pos); Effects: If fail() != true, executes rdbuf()->pubseekpos(pos).
To:
basic_istream<charT,traits>& seekg(pos_type pos); Effects: If fail() != true, executes rdbuf()->pubseekpos(pos, ios_base::in).
In section 27.6.1.3 change:
basic_istream<charT,traits>& seekg(off_type& off, ios_base::seekdir dir); Effects: If fail() != true, executes rdbuf()->pubseekoff(off, dir).
To:
basic_istream<charT,traits>& seekg(off_type& off, ios_base::seekdir dir); Effects: If fail() != true, executes rdbuf()->pubseekoff(off, dir, ios_base::in).
In section 27.6.2.4, paragraph 2 change:
-2- Effects: If fail() != true, executes rdbuf()->pubseekpos(pos).
To:
-2- Effects: If fail() != true, executes rdbuf()->pubseekpos(pos, ios_base::out).
In section 27.6.2.4, paragraph 4 change:
-4- Effects: If fail() != true, executes rdbuf()->pubseekoff(off, dir).
To:
-4- Effects: If fail() != true, executes rdbuf()->pubseekoff(off, dir, ios_base::out).
I may be misunderstanding the intent, but should not seekg set only the input stream and seekp set only the output stream? The description seems to say that each should set both input and output streams. If that's really the intent, I withdraw this proposal.
History | |||
---|---|---|---|
Date | User | Action | Args |
2010-10-21 18:28:33 | admin | set | messages: + msg1651 |
2010-10-21 18:28:33 | admin | set | messages: + msg1650 |
2010-10-21 18:28:33 | admin | set | messages: + msg1649 |
2010-10-21 18:28:33 | admin | set | messages: + msg1648 |
1999-03-06 00:00:00 | admin | create |