std::basic_spanbuf
來自 cppreference.com
定義於標頭檔案 <spanstream> |
||
template< class CharT, |
(C++23 起) | |
std::basic_spanbuf
是 std::basic_streambuf,其關聯字元序列是記憶體駐留的任意字元序列,可以從 std::span<CharT> 例項初始化或提供為該例項。
std::basic_spanbuf
在固定緩衝區上執行 I/O,因此當底層緩衝區耗盡時,它不會嘗試獲取新緩衝區。
提供了用於常見字元型別的幾個 typedef
定義於標頭檔案
<spanstream> | |
型別 | 定義 |
std::spanbuf
|
std::basic_spanbuf<char> |
std::wspanbuf
|
std::basic_spanbuf<wchar_t> |
目錄 |
[編輯] 成員型別
成員型別 | 定義 |
char_type
|
CharT |
traits_type
|
Traits ;如果 Traits::char_type 不是 CharT ,則程式格式錯誤。 |
int_type
|
Traits::int_type |
pos_type
|
Traits::pos_type |
off_type
|
Traits::off_type |
[編輯] 資料成員
成員名稱 (Member name) | 定義 |
mod (私有) |
記錄開啟模式的 std::ios_base::openmode。 (僅用於闡釋的成員物件*) |
buf (私有) |
引用底層緩衝區的 std::span<CharT>。 (僅用於闡釋的成員物件*) |
[編輯] 成員函式
公開成員函式 | |
構造 basic_spanbuf 物件(public 成員函式) | |
(解構函式) [虛] |
銷燬 basic_spanbuf 物件(虛公共成員函式) |
賦值 basic_spanbuf 物件(public 成員函式) | |
交換兩個 basic_spanbuf 物件(public 成員函式) | |
根據模式獲取或初始化底層緩衝區 (public 成員函式) | |
受保護的成員函式 | |
[虛] |
嘗試用陣列替換受控字元序列 (virtual protected 成員函式) |
[虛] |
使用相對定址重新定位輸入序列、輸出序列或兩者的下一個指標 (virtual protected 成員函式) |
[虛] |
使用絕對定址重新定位輸入序列、輸出序列或兩者的下一個指標 (virtual protected 成員函式) |
[編輯] 非成員函式
特化 std::swap 演算法 (函式模板) |
繼承自 std::basic_streambuf
成員型別
成員型別 | 定義 |
char_type
|
CharT |
traits_type
|
Traits ;如果 Traits::char_type 不是 CharT ,則程式格式錯誤。 |
int_type
|
Traits::int_type |
pos_type
|
Traits::pos_type |
off_type
|
Traits::off_type |
成員函式
[虛] |
銷燬 basic_streambuf 物件( std::basic_streambuf<CharT,Traits> 的虛 public 成員函式) |
區域設定 | |
更改關聯的區域設定並呼叫 imbue() ( std::basic_streambuf<CharT,Traits> 的 public 成員函式) | |
獲取關聯區域設定的副本 ( std::basic_streambuf<CharT,Traits> 的 public 成員函式) | |
定位 | |
呼叫 setbuf() ( std::basic_streambuf<CharT,Traits> 的 public 成員函式) | |
呼叫 seekoff() ( std::basic_streambuf<CharT,Traits> 的 public 成員函式) | |
呼叫 seekpos() ( std::basic_streambuf<CharT,Traits> 的 public 成員函式) | |
呼叫 sync() ( std::basic_streambuf<CharT,Traits> 的 public 成員函式) | |
獲取區 | |
獲取獲取區中立即可用的字元數 ( std::basic_streambuf<CharT,Traits> 的 public 成員函式) | |
推進輸入序列,然後讀取一個字元而不再次推進 ( std::basic_streambuf<CharT,Traits> 的 public 成員函式) | |
(C++17 中移除) |
從輸入序列中讀取一個字元並推進序列 ( std::basic_streambuf<CharT,Traits> 的 public 成員函式) |
從輸入序列中讀取一個字元而不推進序列 ( std::basic_streambuf<CharT,Traits> 的 public 成員函式) | |
呼叫 xsgetn() ( std::basic_streambuf<CharT,Traits> 的 public 成員函式) | |
放置區 | |
將一個字元寫入放置區並推進下一個指標 ( std::basic_streambuf<CharT,Traits> 的 public 成員函式) | |
呼叫 xsputn() ( std::basic_streambuf<CharT,Traits> 的 public 成員函式) | |
回放 | |
將一個字元放回輸入序列 ( std::basic_streambuf<CharT,Traits> 的 public 成員函式) | |
將輸入序列中的下一個指標後退一個位置 ( std::basic_streambuf<CharT,Traits> 的 public 成員函式) |
受保護的成員函式
構造 basic_streambuf 物件(protected 成員函式) | |
(C++11) |
替換 basic_streambuf 物件(protected 成員函式) |
(C++11) |
交換兩個 basic_streambuf 物件(protected 成員函式) |
區域設定 | |
[虛] |
響應關聯區域設定的更改 ( std::basic_streambuf<CharT,Traits> 的虛 protected 成員函式) |
定位 | |
[虛] |
如果允許,用使用者定義的陣列替換緩衝區 ( std::basic_streambuf<CharT,Traits> 的虛 protected 成員函式) |
[虛] |
使用相對定址重新定位輸入序列、輸出序列或兩者的下一個指標 ( std::basic_streambuf<CharT,Traits> 的虛 protected 成員函式) |
[虛] |
使用絕對定址重新定位輸入序列、輸出序列或兩者的下一個指標 ( std::basic_streambuf<CharT,Traits> 的虛 protected 成員函式) |
[虛] |
將緩衝區與關聯的字元序列同步 ( std::basic_streambuf<CharT,Traits> 的虛 protected 成員函式) |
獲取區 | |
[虛] |
如果已知,獲取關聯輸入序列中可用於輸入的字元數 ( std::basic_streambuf<CharT,Traits> 的虛 protected 成員函式) |
[虛] |
從關聯輸入序列中讀取字元到獲取區 ( std::basic_streambuf<CharT,Traits> 的虛 protected 成員函式) |
[虛] |
從關聯輸入序列中讀取字元到獲取區並推進下一個指標 ( std::basic_streambuf<CharT,Traits> 的虛 protected 成員函式) |
[虛] |
從輸入序列中讀取多個字元 ( std::basic_streambuf<CharT,Traits> 的虛 protected 成員函式) |
返回獲取區起始、當前字元和結尾的指標 (protected 成員函式) | |
推進輸入序列中的下一個指標 (protected 成員函式) | |
重新定位輸入序列的起始、下一個和結束指標 (protected 成員函式) | |
放置區 | |
[虛] |
向輸出序列寫入多個字元 ( std::basic_streambuf<CharT,Traits> 的虛 protected 成員函式) |
[虛] |
從放置區向關聯輸出序列寫入字元 ( std::basic_streambuf<CharT,Traits> 的虛 protected 成員函式) |
返回放置區起始、當前字元和結尾的指標 (protected 成員函式) | |
推進輸出序列的下一個指標 (protected 成員函式) | |
重新定位輸出序列的起始、下一個和結束指標 (protected 成員函式) | |
回放 | |
[虛] |
將一個字元放回輸入序列,可能會修改輸入序列 ( std::basic_streambuf<CharT,Traits> 的虛 protected 成員函式) |
[編輯] 註釋
std::basic_spanbuf
不擁有底層緩衝區。
程式設計師有責任確保底層緩衝區在使用 std::basic_spanbuf
物件時處於其生命週期內。如果多個執行緒透過不同的 std::basic_spanbuf
物件操作相同的底層緩衝區,可能需要額外的同步。
特性測試宏 | 值 | 標準 | 特性 |
---|---|---|---|
__cpp_lib_spanstream |
202106L |
(C++23) | std::spanbuf , std::spanstream |
[編輯] 另請參閱
實現原始字串裝置 (類模板) | |
(在 C++98 中已廢棄)(在 C++26 中已移除) |
實現原始字元陣列裝置 (類) |