gpt4 book ai didi

c++ - std::basic_filebuf::seekpos 的文档

转载 作者:太空狗 更新时间:2023-10-29 21:32:53 26 4
gpt4 key购买 nike

我研究了由 cppreference.com 提供的 std::basic_filebuf::seekpos 的文档页面。并被以下句子弄糊涂了:

If the file is open for reading, updates the get area if necessary.

据我在计算机上看到的,seekpos 以 eback()==gptr()==egptr() 结束,即函数清空获取区域。这是否意味着获取区域已更新?如果有人能澄清一下,那就太好了。谢谢!

最佳答案

从页面的下方开始:

Many implementations do not update the get area in seekpos(), delegating to underflow() that is called by the next sgetc()

和:

on some implementations, the get area is emptied by seekpos() and the second underflow() is necessary to observe the effects

看来你就是这样。

“更新”的含义有多种解释。该标准在这里非常灵活(注意缺少明确的后置条件),基本上是说“实现可以做任何它需要做的事情以开展其业务”。

在这种特殊情况下,您的 filebuf 实现可能在您查找时清空了获取区域,然后将在下一个 underflow() 时“填充”它 — 可以说这两个操作一致是“更新”,但老实说您可以以您喜欢的方式旋转它。

关于c++ - std::basic_filebuf::seekpos 的文档,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53525238/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com