Share via


<sstream>

定義數個類別範本,這些範本支援儲存在配置陣列物件中之序列上的 iostreams 作業。 這類序列可以輕鬆地從類別範本 的物件basic_string來回轉換。

語法

namespace std {
template <class CharType, class Traits = char_traits<CharType>, class Allocator = allocator<CharType>>
class basic_stringbuf;
typedef basic_stringbuf<char>
stringbuf;
typedef basic_stringbuf<wchar_t> wstringbuf;

template <class CharType, class Traits = char_traits<CharType>, class Allocator = allocator<CharType>>
class basic_istringstream;
typedef basic_istringstream<char>
istringstream;
typedef basic_istringstream<wchar_t> wistringstream;

template <class CharType, class Traits = char_traits<CharType>, class Allocator = allocator<CharType>>
class basic_ostringstream;
typedef basic_ostringstream<char>
ostringstream;
typedef basic_ostringstream<wchar_t> wostringstream;

template <class CharType, class Traits = char_traits<CharType>, class Allocator = allocator<CharType>>
class basic_stringstream;
typedef basic_stringstream<char>
stringstream;
typedef basic_stringstream<wchar_t> wstringstream;
// TEMPLATE FUNCTIONS
template <class CharType, class Traits, class Allocator>
void swap(
    basic_stringbuf<CharType, Traits, Allocator>& left,
    basic_stringbuf<CharType, Traits, Allocator>& right);

template <class CharType, class Traits, class Allocator>
void swap(
    basic_istringstream<CharType, Traits, Allocator>& left,
    basic_istringstream<CharType, Traits, Allocator>& right);

template <class CharType, class Traits, class Allocator>
void swap(
    basic_ostringstream<CharType, Traits, Allocator>& left,
    basic_ostringstream<CharType, Traits, Allocator>& right);

template <class CharType, class Traits, class Allocator>
void swap (
    basic_stringstream<CharType, Traits, Allocator>& left,
    basic_stringstream<CharType, Traits, Allocator>& right);

}  // namespace std

參數

left
sstream 物件的參考。

right
sstream 物件的參考。

備註

char * 別的物件可以使用 strstream > 中的 < 功能進行串流處理。 不過, < strstream > 已被取代,而且鼓勵使用 < sstream > 。

Typedefs

類型名稱 描述
istringstream 建立已在 char 樣板參數上特製化的 basic_istringstream 類型。
ostringstream 建立已在 char 樣板參數上特製化的 basic_ostringstream 類型。
stringbuf 建立已在 char 樣板參數上特製化的 basic_stringbuf 類型。
stringstream 建立已在 char 樣板參數上特製化的 basic_stringstream 類型。
wistringstream 建立已在 wchar_t 樣板參數上特製化的 basic_istringstream 類型。
wostringstream 建立已在 wchar_t 樣板參數上特製化的 basic_ostringstream 類型。
wstringbuf 建立已在 wchar_t 樣板參數上特製化的 basic_stringbuf 類型。
wstringstream 建立已在 wchar_t 樣板參數上特製化的 basic_stringstream 類型。

操作工具

名稱 描述
swap sstream 物件之間交換值。

類別

類別 描述
basic_stringbuf 描述資料流緩衝區,其控制類型 Elem 的項目 (其字元特性由類別 Tr 所決定),與陣列物件中儲存的項目序列之間的往來傳輸。
basic_istringstream 描述物件,這個物件會控制從類別資料流程緩衝區擷取專案和編碼物件, < 其類別 basic_stringbuf Elem , Tr , >Alloc 具有 類型的 Elem 元素,其字元特性是由 類別所決定,以及其專案是由 類別 TrAlloc 的配置器所配置。
basic_ostringstream 描述物件,控制將專案和編碼物件插入類別 的資料流程緩衝區,basic_stringbuf < Elem Tr , >Alloc ,其 Elem 類型為 的專案,其字元特性是由 類別所決定,以及其專案是由 類別 TrAlloc 的配置器所配置。
basic_stringstream 描述物件,此物件會使用 類別 basic_stringbuf的資料流程緩衝區,控制 < 元素和編碼物件的插入和擷取,其類型為 的 >Alloc 元素 Elem ,其字元特性是由 類別所決定,以及其專案是由 類別 Tr 的配置 Alloc 器所配置。

需求

  • Header: < sstream>

  • 命名空間:std

另請參閱

標頭檔參考
C++ 標準程式庫中的執行緒安全
iostream 程式設計
iostreams 慣例