|
Boost : |
From: Caleb Epstein (caleb.epstein_at_[hidden])
Date: 2005-02-16 10:44:20
On Tue, 15 Feb 2005 23:11:49 -0500, Jason Hise <chaos_at_[hidden]> wrote:
>
> From everything I know, cin, cout, cerr, and clog are simply global
> variables that live in namespace std. Does this mean that the following
> code is dangerous?
AFAIK yes. If you have a singleton object that is being destroyed at
exit, it is possible that cin/cout/clog etc have been closed before
Log::~Log is called.
> class Log
> {
> public:
> Log ( ) { std::clog << "Log created\n"; }
> ~ Log ( ) { std::clog << "Log destroyed\n"; }
> } global_log;
>
> If so, (and I know this is presumptuous, so strictly hypothetically
> speaking) could these four standard streams benefit by becoming
> singletons? Just a thought experiment...
-- Caleb Epstein caleb dot epstein at gmail dot com
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk