
16 Feb
2005
16 Feb
'05
4:35 p.m.
On Tue, Feb 15, 2005 at 11:11:49PM -0500, Jason Hise 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?
class Log { public: Log ( ) { std::clog << "Log created\n"; } ~ Log ( ) { std::clog << "Log destroyed\n"; } } global_log;
The standard streams are meant to be available for users at any time. Quite how implementations are supposed to achieve this isn't mandated: http://www.open-std.org/JTC1/SC22/WG21/docs/lwg-active.html#369 But I think the intention is that the code above is legal and safe. See 27.3/2 jon