http://en.cppreference.com/w/cpp/io/clog上面写道:
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.
These objects are guaranteed to be initialized during or before the first time an object of type std::ios_base::Init is constructed and are available for use in the constructors and destructors of static objects (as long as <iostream> is included).
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.
问题:
1. clog, wclog到底有没有缓存,到底会不会自动刷新到cerr上面?
2. 假如是没有缓存的,好像cerr也是没有缓存的对吧,那么既然都已经有cerr了,那么clog提供了什么不同的东西吗?
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.
These objects are guaranteed to be initialized during or before the first time an object of type std::ios_base::Init is constructed and are available for use in the constructors and destructors of static objects (as long as <iostream> is included).
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.
问题:
1. clog, wclog到底有没有缓存,到底会不会自动刷新到cerr上面?
2. 假如是没有缓存的,好像cerr也是没有缓存的对吧,那么既然都已经有cerr了,那么clog提供了什么不同的东西吗?
解决方案:40分
cerr 会在每次输出之后清空缓存。
clog 不会。
clog 不会。