<sstream>

Defines several class templates that support iostreams operations on sequences stored in an allocated array object. Such sequences are easily converted to and from objects of class template 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 sstream object.
right Reference to an sstream object.

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

Type name Description
istringstream Creates a type basic_istringstream specialized on a char template parameter.
ostringstream Creates a type basic_ostringstream specialized on a char template parameter.
stringbuf Creates a type basic_stringbuf specialized on a char template parameter.
stringstream Creates a type basic_stringstream specialized on a char template parameter.
wistringstream Creates a type basic_istringstream specialized on a wchar_t template parameter.
wostringstream Creates a type basic_ostringstream specialized on a wchar_t template parameter.
wstringbuf Creates a type basic_stringbuf specialized on a wchar_t template parameter.
wstringstream Creates a type basic_stringstream specialized on a wchar_t template parameter.

Manipulators

swap Exchanges the values between two sstream objects.

Classes

Class Description
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 class Alloc.
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 class Alloc.
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 class Alloc.

Requirements

  • Header: <sstream>

  • Namespace: std

See also

Header Files Reference
Thread Safety in the C++ Standard Library
iostream Programming
iostreams Conventions