- c - 在位数组中找到第一个零
- linux - Unix 显示有关匹配两种模式之一的文件的信息
- 正则表达式替换多个文件
- linux - 隐藏来自 xtrace 的命令
我研究了由 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/
这是来自客户端的代码(使用) struct sockaddr_in stSockAddr; int Res; int SocketFD; SocketFD = socket(P
有谁知道 GNU GCC 的 libstdc++ 中 basic_filebuf 的默认缓冲区大小?我知道成员函数 pubsetbuf() 并且我很确定缓冲区大小是实现定义的。在 C 中很简单,从
我研究了由 cppreference.com 提供的 std::basic_filebuf::seekpos 的文档页面。并被以下句子弄糊涂了: If the file is open for rea
来 self 的 C++ 标准拷贝 [§27.8.2.1p4]: basic_stringbuf(basic_stringbuf&& rhs); Effects: Move constructs fr
假设我想使用 basic_filebuf 读取文件的内容。我有一个名为 boost::uintmax_t 的类型,它的大小为 8 字节。我正在尝试编写以下内容: typedef basic_fileb
为什么下面的代码会抛出异常?请注意,该文件是一个 /proc/pid/stat 文件,因此它可能会受到内核的干扰。 // Checked that file does exist try { st
我正在尝试使用 Microsoft 特定 filebuf::sh_none打开 fstream 的变量在独占模式(另一个 Microsoft 特定功能)。我收到上述错误。我正在进口 .我该如何解决这
我是一名优秀的程序员,十分优秀!