名稱空間
變體
操作

std::basic_streambuf<CharT,Traits>::pubseekoff, std::basic_streambuf<CharT,Traits>::seekoff

來自 cppreference.com
< cpp‎ | io‎ | basic streambuf
 
 
 
 
pos_type pubseekoff( off_type off, std::ios_base::seekdir dir,
                     std::ios_base::openmode which = ios_base::in | ios_base::out );
(1)
protected:

virtual pos_type seekoff( off_type off, std::ios_base::seekdir dir,

                          std::ios_base::openmode which = ios_base::in | ios_base::out );
(2)

設定輸入和/或輸出序列的位置指示器到相對於某個其他位置的位置。

1) 呼叫最派生類的 seekoff(off, dir, which)
2) 此函式的基類版本無效果。派生類可以重寫此函式以允許對位置指示器進行相對定位。

目錄

[編輯] 引數

off - - 用於設定位置指示器的相對位置。
dir - 定義應用相對偏移量的基本位置。它可以是以下常量之一
常量 解釋
beg 流的開始
end 流的結束
cur 流位置指示器的當前位置
which - - 定義影響輸入及/或輸出序列的哪個。它可以是下列常量之一或組合
常量 解釋
in 影響輸入序列
out 影響輸出序列

[編輯] 注意

並非所有引數組合都有效,詳情請參閱 seekoff 的派生版本。

[編輯] 返回值

1) seekoff(off, dir, which) 的返回值
2) 由位置指示器定義的最終絕對位置。基類版本返回 pos_type(off_type(-1))

[編輯] 示例

[編輯] 缺陷報告

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

缺陷報告 應用於 釋出時的行為 正確的行為
LWG 55 C++98 seekoff 的基類版本曾返回
一個未定義的無效流位置
返回 pos_type(off_type(-1))

[編輯] 參閱

呼叫 seekpos()
(公開成員函式) [編輯]
使用相對地址重新定位檔案位置
std::basic_filebuf<CharT,Traits> 的虛保護成員函式) [編輯]
使用相對定址重新定位輸入序列、輸出序列或兩者的下一個指標
std::basic_stringbuf<CharT,Traits,Allocator> 的虛保護成員函式) [編輯]
使用相對定址重新定位輸入序列、輸出序列或兩者的下一個指標
std::strstreambuf 的虛保護成員函式) [編輯]