C++流问题(代码中注释的解释)
我正在使用 此处 找到的 fastCGI 应用程序。
代码中的注释如下:
if (content) delete []content;
// If the output streambufs had non-zero bufsizes and
// were constructed outside of the accept loop (i.e.
// their destructor won't be called here), they would
// have to be flushed here.
我对 C++ 流的了解相当薄弱。有人可以解释一下以下内容:
- 评论中引用了哪些streambufs?
- 在什么条件下,streambufs 的 bufsize 会非零?
最后但并非最不重要的一点是,有人可以指出一个在线资源(双关语),它提供了对 C++ IO 流的清晰但温和的介绍吗?
I am playing around with the fastCGI application found here.
The following comment is in the code:
if (content) delete []content;
// If the output streambufs had non-zero bufsizes and
// were constructed outside of the accept loop (i.e.
// their destructor won't be called here), they would
// have to be flushed here.
My knowledge of C++ streams is rather weak. Could someone please explain the following:
- which streambufs are being referred to in the comment?
- under what conditions would the streambufs had non-zero bufsizes?
last but not the least, can someone point to a resource (pun intended) online that provides a clear but gentle introduction to C++ IO streams?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
它指的是
request.out
,它是重新分配的cout
的一部分:此重新分配意味着用户可以调用
并在任一控制台上显示文本(例如测试)或作为 CGI 应用程序运行时通过网络。因此,一个代码示例可以在多种环境中运行。
您提到的评论是一个友好的提醒。此示例代码中的
fcgi_streambuf
对象是在循环中构造的;当循环结束时,它们超出范围并因此被破坏。该评论警告说,在许多情况下,用户必须刷新输出流:
It's referring to
request.out
, which is part of the reassignedcout
:This reassignment means that the user can call
and have the text show-up on either the console (for testing) or across the network when run as a CGI application. Thus, one code sample can run in multiple environments.
The comment you're referring to is a friendly reminder. The
fcgi_streambuf
objects in this sample code are constructed in a loop; when the loop ends, they go out of scope and are thus destructed.The comment warns that in many circumstances, the user would have to flush the output stream: