std::basic_ostringstream<CharT,Traits,Allocator>::basic_ostringstream (3) - Linux Manuals
std::basic_ostringstream<CharT,Traits,Allocator>::basic_ostringstream: std::basic_ostringstream<CharT,Traits,Allocator>::basic_ostringstream
NAME
std::basic_ostringstream<CharT,Traits,Allocator>::basic_ostringstream - std::basic_ostringstream<CharT,Traits,Allocator>::basic_ostringstream
Synopsis
basic_ostringstream() : basic_ostringstream(ios_base::out) { } (1) (since C++11)
explicit basic_ostringstream( ios_base::openmode mode = ios_base::out ); (until C++11)
explicit basic_ostringstream( ios_base::openmode mode ); (since C++11)
explicit basic_ostringstream( const std::basic_string<CharT,Traits,Allocator>& str, (2) (3)
ios_base::openmode mode = ios_base::out );
basic_ostringstream( basic_ostringstream&& other ); (4) (since C++11)
Constructs new string stream.
1) Default constructor. Constructs new underlying string device with the default open mode
2) Constructs new underlying string device. The underlying basic_stringbuf object is constructed as basic_stringbuf<Char,Traits,Allocator>(mode | ios_base::out).
3) Uses a copy of str as initial contents of the underlying string device. The underlying basic_stringbuf object is constructed as basic_stringbuf<Char,Traits,Allocator>(str, mode | ios_base::out).
4) Move constructor. Constructs the string stream with the state of other using move semantics.
Parameters
str - string to use as initial contents of the string stream
mode - binary open in binary_mode
other - another string stream to use as source
Notes
Construction of one-off basic_ostringstream objects in a tight loop, such as when used for string conversion, may be significantly more costly than calling str to reuse the same object.
Defect reports
The following behavior-changing defect reports were applied retroactively to previously published C++ standards.
DR Applied to Behavior as published Correct behavior
P0935R0 C++11 default constructor was explicit made implicit
Example
// Run this code
Output:
See also
str (public member function)
constructor (public member function of std::basic_stringbuf<CharT,Traits,Allocator>)