From: John Torjo (john.lists_at_[hidden])
Date: 2003-10-10 01:02:38
I came a little late - sorry about that.
Anyway, I have a more thorough implementation of nullstream,
since there are more details that could be taken into considerance.
I've attached the code - if anyone is interested, I can comment on them
The idea is that you might need to sometimes pass nullstream to a function
taking an ostream& reference.
At this point you have two options:
- ignoreoutput (which silently ignores output)
- failbit - which is much faster than ignoreoutput, since it sets the
std::ios::failbit on the stream. Internally, when something is written to
first a check is performed to see if the stream is in good state. If it's
function ends right there.
----- Original Message -----
From: "Jeff Garland" <jeff_at_[hidden]>
To: "Boost mailing list" <boost_at_[hidden]>
Sent: Thursday, September 25, 2003 2:24 PM
Subject: Re: [boost] streams - basic_nullbuf
> On Thu, 25 Sep 2003 Lars Gullik Bjønnes wrote
> > Jeff Garland wrote:
> > > My approach was a bit different in that I didn't bother with the
> > > all, but created the ostream interface directly in hope that the
> >But if you are going to compile anyway, then you could use other
> >methods as well (pre-processor).
> Yes, but macros are evil and impact code readability. I just really hate
> of code like:
> TRACE("I'm here" << foo << std::endl);
> The all caps thing is really bothersome to me. And of course there is the
> loss of ability to set have a tracing version and a non-tracing version in
> compilation unit.
> > How will this behave for user defined types?
> Same because of omitted detail below...
> > Do I have to add a operator<< for both ostream and null_ostream?
> template<class T>
> operator<<(null_ostream& os, const T&)
> return os;
> I'm not saying my idea was fully baked -- there may be some fatal flaw I
> haven't worked out. Just wanted to point out other potential approaches
> requirements while expressing support for getting something like this in
> Unsubscribe & other changes:
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk