名稱空間
變體
操作

std::fpos<State>::state

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

管理檔案位置狀態。

1) 返回檔案位置狀態的值。
2) 將檔案位置狀態替換為 st 的值。

對於標準庫中使用的 std::fpos 特化,State 始終是 std::mbstate_t

目錄

[編輯] 引數

st - 狀態的新值

[編輯] 返回值

1) fpos 狀態的當前值。
2) (無)

[編輯] 示例

#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

[編輯] 缺陷報告

下列更改行為的缺陷報告追溯地應用於以前出版的 C++ 標準。

缺陷報告 應用於 釋出時的行為 正確的行為
LWG 441 C++98 過載 (1) 未宣告為 const(它在概要中是 const 添加了 const

[編輯] 另請參閱

迭代多位元組字串所需的轉換狀態資訊
(類) [編輯]