protected virtual member function
<sstream>
streampos seekoff (streamoff off, ios_base::seekdir way, ios_base::openmode which = ios_base::in | ios_base::out);
將位置指標設定為相對位置
設定一個新位置給由引數 which 指定的位置指標。此位置是相對於 way 指定的原點計算的 off 個字元的偏移量。
如果 which 包含 ios_base::in,則會影響get指標(gptr),如果 which 包含 ios_base::out,則會影響put指標(pptr)。一次呼叫可以同時影響兩個位置指標。
此虛擬函式由公共成員 streambuf::pubseekoff 呼叫。
引數
- off
- 偏移量,相對於 way 引數。
streamoff 是一個有符號整數型別。
- way
- 型別為 ios_base::seekdir 的物件,指示偏移量應用的來源。它可以取以下任意常量值:
值 | 偏移量相對於... |
ios_base::beg | 字元序列的開頭 |
ios_base::cur | get指標(gptr)或put指標(pptr)的當前位置,具體取決於引數 which。
|
ios_base::end | 字元序列的結尾 |
- which
- 確定受影響的位置指標:輸入序列、輸出序列或兩者。它是 ios_base::openmode 型別的物件,對於此函式,它可以接受以下任意組合的有效常量值
值 | 受影響的位置指標 |
ios_base::in | 修改get指標(gptr) |
ios_base::out | 修改put指標(pptr) |
兩個指標可以同時選擇,但如果當 way 為 ios_base::cur 時同時選擇了兩者,則函式會失敗。
異常安全
基本保證:如果丟擲異常,物件處於有效狀態。