This is the mail archive of the
libstdc++@gcc.gnu.org
mailing list for the libstdc++ project.
Re: RFC: basic_filebuf supporting non-modal I/O without seekpos
- From: Paolo Carlini <paolo dot carlini at oracle dot com>
- To: David Krauss <potswa at mac dot com>
- Cc: libstdc++ at gcc dot gnu dot org, "Nathan C. Myers" <ncm at cantrip dot org>
- Date: Mon, 20 Sep 2010 00:34:35 +0200
- Subject: Re: RFC: basic_filebuf supporting non-modal I/O without seekpos
- References: <15F914AD-EE57-4F52-9F66-50EB5A329874@mac.com>
On 09/18/2010 08:36 AM, David Krauss wrote:
> @@ -410,8 +426,16 @@
> int_type __ret = traits_type::eof();
> const bool __testeof = traits_type::eq_int_type(__c, __ret);
> const bool __testout = _M_mode & ios_base::out;
> - if (__testout && !_M_reading)
> + if (__testout)
> {
> + if (_M_reading)
> + {
> + _M_destroy_pback();
> + const int __gptr_off = _M_get_ext_pos(_M_state_last);
> + if (_M_seek(__gptr_off, ios_base::cur, _M_state_last)
> + == pos_type(off_type(-1)))
> + return __ret;
> + }
>
By the way, as far as I'm concerned, this is the key idea I was missing,
not having seriously looked at these mechanisms for many years: a
sort-of lazy seek, which we are able to delay to when it's really
necessary, when we switch from reading to writing without an explicit
seek in the middle, and we cannot avoid adjusting the file position.
Thanks David for working out this stuff.
Paolo.