关于streambuf溢出功能的查询

发布于 2024-09-24 06:34:52 字数 358 浏览 1 评论 0原文

仔细阅读溢出函数文档。我发现溢出有以下作为返回值。

返回值:

不同于 EOF(或其他特征的 Traits::eof())的值表示成功。

如果函数失败,则返回 EOF(或用于其他特征的 Traits::eof())或引发异常。

来源:“http://www.cplusplus.com/reference/iostream/streambuf/溢出/

谁能告诉我溢出函数在哪个场景中会通过异常? 任何帮助将不胜感激

Going thorugh overflow function documentation. I found overflow has following as return values.

Return Value:

A value different than EOF (or traits::eof() for other traits) signals success.

If the function fails, either EOF (or traits::eof() for other traits) is returned or an exception is thrown.

source :"http://www.cplusplus.com/reference/iostream/streambuf/overflow/"

Can anyone please tell me in which sceanrios is overflow function going to through an exception?
Any help will be appreciated

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

濫情▎り 2024-10-01 06:34:52

Streambuf 是流的底层存储或通信通道的抽象。由于存储或通道失败的任何原因,overflow() 函数都可能失败。例如,磁盘文件的磁盘错误、套接字连接断开等。

Streambuf is abstraction for stream's underlying storage or communication channel. The overflow() function can fail for any reasons the storage or channel can fail. E.g. disk error for disk files, broken connection for sockets etc.

调妓 2024-10-01 06:34:52

Although wilx detailed the fail (EOF) condition, the exception condition can be either one of these: http://www.aoc.nrao.edu/php/tjuerges/ALMA/STL/html-3.4.6/classstd_1_1exception.html (can you guess which one? :) -- but it should (obviously) be std::overflow_error if you're writing your own output stream or something.

命比纸薄 2024-10-01 06:34:52

在我的有问题的场景中,它失败了,因为它没有跳转下一个地址(setp 调用递增 0),因此重试使用相同的内存区域并给出分段错误。

In my problematic scenario it was faling because it was not jumping the next address(setp calls was incrementating by 0) so retrying to use the same memory region and was giving segmentation fault.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文