How about specific implementations pre-C++0x? Well, for example, here is the source code for basic_streambuf<...>:sputc from GCC 4.5.2 ("streambuf" header):
So with this implementation, obviously it is possible for two threads' output to corrupt each other (没有 just interleave).
这段代码会破坏数据结构本身吗?答案取决于这些函数之间可能的交互; 例如,如果一个线程试图刷新缓冲区,而另一个线程试图调用 xsputn或其他什么,会发生什么情况。这可能取决于您的编译器和 CPU 决定如何重新排序内存负载和存储; 这需要仔细分析才能确定。这还取决于如果两个线程试图同时修改相同的位置,您的 CPU 将执行什么操作。
In other words, even if it happens to work fine in your current environment, it might break when you update any of your runtime, compiler, or CPU.