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


thanx for fast reply Paolo... 

On Saturday 16 October 2004 22:59, Paolo Carlini wrote:
> Hi,
>
> zaufi@sendmail.ru wrote:
> >3) ostream::put() calls NON VIRTUAL function base_streambuf::sputc() !! --
> > so there is no way to redefine it in derived classes... :(((
>
> Maybe I'm missing some details (I will read again your message
> later), but, if this is your main point, there is little doubt
> that, according to the ISO standard that we are implementing,
> this is right behavior. See 27.6.2.1/2, in particular:
>
In current (I have gcc 3.4.1 at home and 3.4.2 at work) implementation 
ostream::put() uses rdbuf() to get pointer to currently configured streambuf. 
In my case it is syslogbuf (which is derived from std::streambuf). So when 
pointer to my class casted to base_streambuf*, ostream::put() call 
'wrong' (base_streambuf::sputc() instead of syslogbuf::sputc()) function... 
If this is normal can you please explain me right way to handle std::endl 
outputing using base_streambuf::xsputn() redifinition...

> "... Both groups of output functions generate (or _insert_)
> output characters by actions equivalent to calling
> rdbuf->sputc(int_type). They may use other public members of
> basic_ostream except that they do not invoke any virtual
> members of rdbuf() except overflow()."
>
As I see in your cite standart say nothing about should rdbuf->sputc() be 
virtual or not ... ;)

---
I can attach my syslog_stream.hh if you need it... I hope it quite simple for 
reading and understanding what I'm talking about...


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