This is the mail archive of the libstdc++@sourceware.cygnus.com 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]

stream buffers - 3 questions



bits/std_sstream.h, 62:
      // Constructors:
      explicit
      basic_stringbuf(ios_base::openmode __mode = ios_base::in |
                                                  ios_base::out)
      : __streambuf_type(), _M_str(__string_type())
      {
        _M_mode = __mode;
        this->sync();
      }

1. Is there any reason for _M_str(__string_type()) instead of _M_str()?

bits/std_sstream.h, 109:
      virtual __streambuf_type*
      setbuf(char_type* __s, streamsize __n)
      {
        __string_type __str(__s, __n);
        if (__str.size())
          this->str(__str);
        return dynamic_cast<__streambuf_type*> (this);
      }

2. basic_stringbuf inherits from __streambuf_type. Why the dynamic_cast?!
Should the return value be a __streambuf_type* or perhaps it can be
a basic_stringbuf* ?
I would write:
      virtual basic_stringbuf<_CharT, _Traits, _Alloc>*
      setbuf(char_type* __s, streamsize __n)
      {
        if (n) {
          _M_str.assign(__s, __n);
          this->sync();
        }
        return this;
      }


bits/std_streambuf.h, 244:
      // Buffer management and positioning:
      virtual basic_streambuf<char_type,_Traits>*
      setbuf(char_type* __s, streamsize __n)
      {
        if (this->gptr() && this->gptr() != this->egptr())
          return this;
      }
3. I suppose this function is not ready jet? 
No return value wolud be returned if 'if (false)' occurs.


Ryszard Kabatek
Martin-Luther University Halle-Wittenberg, Department of Physical Chemistry
Geusaer Str. 88, 06217 Merseburg, Germany
Tel. +49 3461 46 2487 (2466) Fax. +49 3461 46 2129


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