This is the mail archive of the libstdc++@gcc.gnu.org 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: [Q] Problem with derived from streambuf class


zaufi@sendmail.ru wrote:

If this is normal can you please explain me right way to handle std::endl

Probably there are other ways to deal with this issue, but what I would suggest
now is just reimplementing std::endl.


 template<class charT, class traits>
   basic_ostream<charT, traits>& endl(basic_ostream<charT, traits>& os);

In the standard, its behavior is: os.put(os.widen('\n')), then os.flush(). The
latter, in turn, boils down to rdbuf()-pubsync(), which simply calls the
streambuf::sync() virtual. The latter is basically an overflow().


Therefore, in implementing it, you would directly use syslogbuf::sputc() (instead
of os.put which ends up calling the "wrong" sputc()), and syslogbuf::overflow()
(yes, unfortunately I think that in general you should redefine it, besides xsputn)


I hope you will find these few lines useful: in my opinion, if you are going to
heavily work on such topics, I should get a good book, like Langer & Kreft.


Paolo.


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