namespace std { template <class charT, class traits = char_traits<charT>, class Allocator = allocator<charT>> class basic_ostringstream : public basic_ostream<charT, traits> { public: using char_type = charT; using int_type = typename traits::int_type; using pos_type = typename traits::pos_type; using off_type = typename traits::off_type; using traits_type = traits; using allocator_type = Allocator; // [ostringstream.cons], constructors explicit basic_ostringstream( ios_base::openmode which = ios_base::out); explicit basic_ostringstream( const basic_string<charT, traits, Allocator>& str, ios_base::openmode which = ios_base::out); basic_ostringstream(const basic_ostringstream& rhs) = delete; basic_ostringstream(basic_ostringstream&& rhs); // [ostringstream.assign], assign and swap basic_ostringstream& operator=(const basic_ostringstream& rhs) = delete; basic_ostringstream& operator=(basic_ostringstream&& rhs); void swap(basic_ostringstream& rhs); // [ostringstream.members], members basic_stringbuf<charT, traits, Allocator>* rdbuf() const; basic_string<charT, traits, Allocator> str() const; void str(const basic_string<charT, traits, Allocator>& s); private: basic_stringbuf<charT, traits, Allocator> sb; // exposition only }; template <class charT, class traits, class Allocator> void swap(basic_ostringstream<charT, traits, Allocator>& x, basic_ostringstream<charT, traits, Allocator>& y); }
Класс basic_ostringstream<charT, traits, Allocator> поддерживает запись объектов класса basic_string<charT, traits, Allocator>. Он использует basic_stringbuf объект для управления связанным хранилищем. Для демонстрации поддерживаемые данные представлены здесь как:
sb, stringbuf объект.
explicit basic_ostringstream(
ios_base::openmode which = ios_base::out);
Effects: Создает объект класса basic_ostringstream, инициализируя базовый класс с помощью basic_ostream(&sb) и инициализируя sb с помощью basic_stringbuf<charT, traits, Allocator>(which | ios_base::out)) ([stringbuf.cons]).
explicit basic_ostringstream(
const basic_string<charT, traits, Allocator>& str,
ios_base::openmode which = ios_base::out);
Effects: Создает объект класса basic_ostringstream<charT, traits>, инициализируя базовый класс с помощью basic_ostream(&sb) и инициализируя sb с помощью basic_stringbuf<charT, traits, Allocator>(str, which | ios_base::out)) ([stringbuf.cons]).
basic_ostringstream(basic_ostringstream&& rhs);
basic_ostringstream& operator=(basic_ostringstream&& rhs);
void swap(basic_ostringstream& rhs);
Effects: Меняет состояние *this и rhs по вызову basic_ostream<charT, traits>::swap(rhs) и sb.swap(rhs.sb).
template <class charT, class traits, class Allocator>
void swap(basic_ostringstream<charT, traits, Allocator>& x,
basic_ostringstream<charT, traits, Allocator>& y);
basic_stringbuf<charT, traits, Allocator>* rdbuf() const;
basic_string<charT, traits, Allocator> str() const;
void str(const basic_string<charT, traits, Allocator>& s);