命名空间
变体
操作

std::fpos<State>::state

来自 cppreference.cn
< cpp‎ | io‎ | fpos
State state() const;
(1)
void state( State st );
(2)

管理文件位置状态。

1) 返回文件位置状态的值。
2) 将文件位置状态替换为 st 的值。

对于标准库中使用的 std::fpos 的特化,State 始终是 std::mbstate_t。

目录

[edit] 参数

st - 状态的新值

[edit] 返回值

1) fpos 状态的当前值。
2) (无)

[edit] 示例

#include <cwchar>
#include <iostream>
#include <sstream>
 
int main()
{
    std::istringstream s("test");
    std::mbstate_t st = s.tellg().state();
 
    if (std::mbsinit(&st))
        std::cout << "The stream is in the initial shift state\n";
}

输出

The stream is in the initial shift state

[edit] 缺陷报告

以下行为变更缺陷报告已追溯应用于先前发布的 C++ 标准。

DR 应用于 已发布行为 正确行为
LWG 441 C++98 重载 (1) 未声明为 const (在概要中它是 const) 添加了 const

[edit] 参见

迭代多字节字符串所需的转换状态信息
(类) [编辑]