std::basic_ostringstream< _CharT, _Traits, _Alloc >(3)

NAME
std::basic_ostringstream< _CharT, _Traits, _Alloc > - Controlling output for std::string.

SYNOPSIS

  Public Types
typedef basic_ostream< char_type, traits_type > __ostream_type
typedef basic_string< _CharT, _Traits, _Alloc > __string_type
typedef basic_stringbuf< _CharT, _Traits, _Alloc > __stringbuf_type
typedef _Alloc allocator_type
typedef _CharT char_type
typedef traits_type::int_type int_type
typedef traits_type::off_type off_type
typedef traits_type::pos_type pos_type
typedef _Traits traits_type

  Public Member Functions
basic_ostringstream ()
Default constructor starts with an empty string buffer.
basic_ostringstream (basic_ostringstream &&__rhs)
basic_ostringstream (const __string_type &__str, ios_base::openmode __mode=ios_base::out)
Starts with an existing string buffer.
basic_ostringstream (const basic_ostringstream &)=delete
basic_ostringstream (ios_base::openmode __mode)
Starts with an empty string buffer.
~basic_ostringstream ()
The destructor does nothing.
basic_ostringstream & operator= (basic_ostringstream &&__rhs)
basic_ostringstream & operator= (const basic_ostringstream &)=delete
__stringbuf_type * rdbuf () const
Accessing the underlying buffer.
__string_type str () const
Copying out the string buffer.
void str (const __string_type &__s)
Setting a new buffer.
void swap (basic_ostringstream &__rhs)

Detailed Description

  template<typename _CharT, typename _Traits, typename _Alloc>
class std::basic_ostringstream< _CharT, _Traits, _Alloc >" Controlling output for std::string.

Template Parameters
    _CharT Type of character stream.
    _Traits Traits for character type, defaults to char_traits<_CharT>.
    _Alloc Allocator type, defaults to allocator<_CharT>.

This class supports writing to objects of type std::basic_string, using the inherited functions from std::basic_ostream. To control the associated sequence, an instance of std::basic_stringbuf is used, which this page refers to as sb.

Definition at line 104 of file iosfwd.

Constructor & Destructor Documentation

  template<typename _CharT , typename _Traits , typename _Alloc > std::basic_ostringstream< _CharT, _Traits, _Alloc >::basic_ostringstream () [inline]

Default constructor starts with an empty string buffer. Initializes sb using mode|out, and passes &sb to the base class initializer. Does not allocate any buffer.

That's a lie. We initialize the base class with NULL, because the string class does its own memory management.

Definition at line 583 of file sstream.

  template<typename _CharT , typename _Traits , typename _Alloc > std::basic_ostringstream< _CharT, _Traits, _Alloc >::basic_ostringstream (ios_base::openmode __mode) [inline], [explicit]

Starts with an empty string buffer.

Parameters
    __mode Whether the buffer can read, or write, or both.

ios_base::out is automatically included in mode.

Initializes sb using mode|out, and passes &sb to the base class initializer. Does not allocate any buffer.

That's a lie. We initialize the base class with NULL, because the string class does its own memory management.

Definition at line 600 of file sstream.

  template<typename _CharT , typename _Traits , typename _Alloc > std::basic_ostringstream< _CharT, _Traits, _Alloc >::basic_ostringstream (const __string_type & __str, ios_base::openmode __mode = ios_base::out) [inline], [explicit]

Starts with an existing string buffer.

Parameters
    __str A string to copy as a starting buffer.
    __mode Whether the buffer can read, or write, or both.

ios_base::out is automatically included in mode.

Initializes sb using str and mode|out, and passes &sb to the base class initializer.

That's a lie. We initialize the base class with NULL, because the string class does its own memory management.

Definition at line 618 of file sstream.

  template<typename _CharT , typename _Traits , typename _Alloc > std::basic_ostringstream< _CharT, _Traits, _Alloc >::~basic_ostringstream () [inline]

The destructor does nothing. The buffer is deallocated by the stringbuf object, not the formatting stream.

Definition at line 629 of file sstream.

Member Function Documentation

  template<typename _CharT , typename _Traits , typename _Alloc > __stringbuf_type* std::basic_ostringstream< _CharT, _Traits, _Alloc >::rdbuf () const [inline]

Accessing the underlying buffer.

Returns
    The current basic_stringbuf buffer.

This hides both signatures of std::basic_ios::rdbuf().

Definition at line 669 of file sstream.

  template<typename _CharT , typename _Traits , typename _Alloc > __string_type std::basic_ostringstream< _CharT, _Traits, _Alloc >::str () const [inline]

Copying out the string buffer.

Returns
    rdbuf()->str()

Definition at line 677 of file sstream.

Referenced by std::__detail::operator<<(), and std::operator<<().

  template<typename _CharT , typename _Traits , typename _Alloc > void std::basic_ostringstream< _CharT, _Traits, _Alloc >::str (const __string_type & __s) [inline]

Setting a new buffer.

Parameters
    __s The string to use as a new sequence.

Calls rdbuf()->str(s).

Definition at line 687 of file sstream.

Author

Generated automatically by Doxygen for libstdc++ from the source code.