std::basic_stringbuf<CharT,Traits,Allocator>::init_buf_ptrs

来自cppreference.com
< cpp‎ | io‎ | basic stringbuf
 
 
 
 
void init_buf_ptrs();
(仅用于阐述*)

根据 mode,以 buf 初始化输入和输出序列。buf 和 mode 是 *this 的 仅用于阐述的数据成员。

在此函数返回后立即满足以下条件:

  • 如果 mode 中设置了 std::ios_base::out,那么 pbase() 指向 buf.front() 且 epptr() >= pbase() + buf.size() 是 true;
    • 另外,如果 mode 中设置了 std::ios_base::ate,那么 pptr() == pbase() + buf.size() 是 true,
    • 否则 pptr() == pbase() 是 true。
  • 如果 mode 中设置了 std::ios_base::in,那么 eback() 指向 buf.front() 且 gptr() == eback() && egptr() == eback() + buf.size() 是 true。

注解

考虑到效率原因,流缓冲区操作可能会违背封装在 std::basic_stringbuf 中的 buf 的不变式,例如写入范围 [buf.data() + buf.size(), buf.data() + buf.capacity()) 中的字符。

所有从 buf 中获取 std::basic_string 的操作都会确保返回值中持有的 std::basic_string 的不变式不会被违背。

缺陷报告

下列更改行为的缺陷报告追溯地应用于以前出版的 C++ 标准。

缺陷报告 应用于 出版时的行为 正确行为
LWG 1448 C++98 init_buf_ptrs() 对于同时是输入流和输出流的流
会使 pptr() == pbase() + buf.data()
对于后附流会使
pptr() == pbase() + buf.size()