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

出自cppreference.com
 
 
 
 
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 的虛受保護成員函數) [編輯]