class template
<sstream>

std::basic_stringstream

template < class charT,                           // basic_stringstream::char_type           class traits = char_traits<charT>,     // basic_stringstream::traits_type           class Alloc = allocator<charT>         // basic_stringstream::allocator_type           > class basic_stringstream;
String stream

Stream class to operate on strings.

Objects of this class use a string buffer that contains a sequence of characters. This sequence of characters can be accessed directly as a basic_string object, using member str.

Characters can be inserted and/or extracted from the stream using any operation allowed on both input and output streams.

Apart from the internal string buffer, objects of these classes keep a set of internal fields inherited from ios_base, basic_ios and basic_istream:

fieldmember functionsdescription
Formattingformat flagsflags
setf
unsetf
A set of internal flags that affect how certain input/output operations are interpreted or generated.
See member type fmtflags.
field widthwidthWidth of the next formatted element to insert.
display precisionprecisionDecimal precision for the next floating-point value inserted.
localegetloc
imbue
The locale object used by the function for formatted input/output operations affected by localization properties.
fill characterfillCharacter to pad a formatted field up to the field width (width).
Stateerror staterdstate
setstate
clear
The current error state of the stream.
Individual values may be obtained by calling good, eof, fail and bad.
See member type iostate.
exception maskexceptionsThe state flags for which a failure exception is thrown.
See member type iostate.
Othercallback stackregister_callbackStack of pointers to functions that are called when certain events occur.
extensible arraysiword
pword
xalloc
Internal arrays to store objects of type long and void*.
tied streamtiePointer to output stream that is flushed before each i/o operation on this stream.
stream bufferrdbufPointer to the associated basic_streambuf object, which is charge of all input/output operations.
character countgcountCount of characters read by last unformatted input operation.

Template parameters

charT
Character type used by both the stream and the basic_string objects it accepts or generates.
This shall be a non-array POD type.
Aliased as member type basic_stringstream::char_type.
traits
Character traits class that defines essential properties of the characters used by stream and string objects (see char_traits).
traits::char_type shall be the same as charT.
Aliased as member type basic_stringstream::traits_type.
Alloc
Type of the allocator object used to define the storage allocation model for the basic_string objects.
By default, the allocator class template is used, which defines the simplest memory allocation model and is value-independent.
Aliased as member type basic_stringstream::allocator_type.

Template instantiations

These instantiations are declared in <sstream>.

Member types

The class declares the following member types:
member typedefinitionnotes
char_typeThe first template parameter (charT)
traits_typeThe second template parameter (traits)defaults to: char_traits<charT>
allocator_typeThe third template parameter (Alloc)defaults to: allocator<charT>
int_typetraits_type::int_type
pos_typetraits_type::pos_typegenerally, the same as streampos
off_typetraits_type::off_typegenerally, the same as streamoff

These member types are inherited from its base classes basic_istream, basic_ostream and ios_base:

Public member functions


Public member functions inherited from basic_istream


Public member functions inherited from basic_ostream


Public member functions inherited from basic_ios


Public member functions inherited from ios_base


Non-member function overloads