Boost logo

Boost :

From: David Abrahams (abrahams_at_[hidden])
Date: 2001-01-27 17:58:41


----- Original Message -----
From: "Ed Brey" <brey_at_[hidden]>

> I would like to raise the issue about providing an external object for
> this functionality. It would seem like a null stream is an object for
> which there would never be a reason to instantiate more than once (at
> least within a single thread). In that case, it is convenient to have a
> predefined object. Having a single global object can be better since time
> is not spent creating and destroying it multiple times, and there is never
> more than one allocated in memory at once. OTOH, having a single global
> object can be worse, since memory for it is always allocated, even when
> zero are in use, and if the program never uses it at all, the startup and
> exit time are wasted. (However, if the program never _references_ it at
> all, it won't get linked in, (right?).)

That optimization is optional, so I wouldn't count on it. IMO, the mechanism
by which implementations generally arrange for cin, cout, and cerr to have
been constructed in advance of their first use is not neccessarily a good
example to follow. It requires that the classes in question can be
initialized separately from their construction, and as I just mentioned,
depends on an optional optimization to avoid linking in lots of code.

> Somewhat on the topic, I'm interested in opinions on adding a debugging
> output stream (dout seems like a good name for the external object) that
> would send its output to whatever is appropriate for the platform. I'd be
> willing to provide a Windows implementation which sends the stream to the
> debugger. The debugger does what it wants to with it (MSVC sends it to a
> dockable output window). Do most other development environments have some
> sort of special debugging output location that can be mapped into.

The Mac doesn't, at least not without stopping the whole machine and
dropping into a machine-level debugger.

I think on Unix what you're referring to is usually called cerr/stderr ;-)


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk