This is the mail archive of the mailing list for the libstdc++ project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: RFC: basic_filebuf supporting non-modal I/O without seekpos

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.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]