std::clog, std::wclog

来自cppreference.com
< cpp‎ | io

定义于头文件 <iostream>
extern std::ostream clog;
(1)
extern std::wostream wclog;
(2)
全球的对象std::clogstd::wclog控制输出流缓冲的实现定义类型(来自std::streambuf),与标准的C输出流stderr,但与std::cerr/std::wcerr,这些流不自动刷新,而不是自动配合( )“法院.....
原文:
The global objects std::clog and std::wclog control output to a stream buffer of implementation-defined type (derived from std::streambuf), associated with the standard C output stream stderr, but, unlike std::cerr/std::wcerr, these streams are not automatically flushed and not automatically tie()'d with cout.
文本通过谷歌翻译机器翻译。
你可以帮忙校正和验证翻译。点击此处查看指示。
保证这些对象被称为以前建造的第一个构造函数中的静态对象,保证他们活​​得比最后的静态对象的析构函数,因此,它始终是在用户代码中写std::clog.
原文:
These objects are guaranteed to be constructed before the first constructor of a static object is called and they are guaranteed to outlive the last destructor of a static object, so that it is always possible to write to std::clog in user code.
文本通过谷歌翻译机器翻译。
你可以帮忙校正和验证翻译。点击此处查看指示。
除非sync_with_stdio(false)已经发出,它是安全的格式化和未格式化的输出都从多个线程同时访问这些对象.
原文:
Unless sync_with_stdio(false) has been issued, it is safe to concurrently access these objects from multiple threads for both formatted and unformatted output.
文本通过谷歌翻译机器翻译。
你可以帮忙校正和验证翻译。点击此处查看指示。

[编辑] 示例

#include <iostream>
struct Foo {
    int n;
    Foo() {
       std::clog << "static constructor\n";
    }
    ~Foo() {
       std::clog << "static destructor\n";
    }
};
Foo f; // static object
int main()
{
    std::clog << "main function\n";
}

输出:

static constructor
main function
static destructor

[编辑] 另请参阅

初始化标准流对象
(std::ios_base 的公开成员类) [编辑]
写入标准 C 错误流 stderr ,无缓冲
(全局对象) [编辑]
写入标准 C 输出流 stdout
(全局对象) [编辑]