std::basic_stringbuf<CharT,Traits,Allocator>:: init_buf_ptrs
|
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 ( ) 对于追加流 |