Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
The latest version of this topic can be found at <sstream>.
Defines several template classes that support iostreams operations on sequences stored in an allocated array object. Such sequences are easily converted to and from objects of template class basic_string.
Syntax
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
Parameters
| Parameter | Description | 
|---|---|
| left | Reference to an sstreamobject. | 
| right | Reference to an sstreamobject. | 
Remarks
Objects of type char * can use the functionality in <strstream> for streaming. However, <strstream> is deprecated and the use of <sstream> is encouraged.
Typedefs
| istringstream | Creates a type basic_istringstreamspecialized on achartemplate parameter. | 
| ostringstream | Creates a type basic_ostringstreamspecialized on achartemplate parameter. | 
| stringbuf | Creates a type basic_stringbufspecialized on achartemplate parameter. | 
| stringstream | Creates a type basic_stringstreamspecialized on achartemplate parameter. | 
| wistringstream | Creates a type basic_istringstreamspecialized on awchar_ttemplate parameter. | 
| wostringstream | Creates a type basic_ostringstreamspecialized on awchar_ttemplate parameter. | 
| wstringbuf | Creates a type basic_stringbufspecialized on awchar_ttemplate parameter. | 
| wstringstream | Creates a type basic_stringstreamspecialized on awchar_ttemplate parameter. | 
Manipulators
| swap | Exchanges the values between two sstreamobjects. | 
Classes
| basic_stringbuf | Describes a stream buffer that controls the transmission of elements of type Elem, whose character traits are determined by the class Tr, to and from a sequence of elements stored in an array object. | 
| basic_istringstream | Describes an object that controls extraction of elements and encoded objects from a stream buffer of class basic_stringbuf<Elem, Tr, Alloc>, with elements of type Elem, whose character traits are determined by the class Tr, and whose elements are allocated by an allocator of classAlloc. | 
| basic_ostringstream | Describes an object that controls insertion of elements and encoded objects into a stream buffer of class basic_stringbuf<Elem, Tr, Alloc>, with elements of type Elem, whose character traits are determined by the class Tr, and whose elements are allocated by an allocator of classAlloc. | 
| basic_stringstream | Describes an object that controls insertion and extraction of elements and encoded objects using a stream buffer of class basic_stringbuf<Elem, Tr, Alloc>, with elements of type Elem, whose character traits are determined by the class Tr, and whose elements are allocated by an allocator of classAlloc. | 
Requirements
- Header: <sstream> 
- Namespace: std 
See Also
Header Files Reference
Thread Safety in the C++ Standard Library
iostream Programming
iostreams Conventions