[ostringstream.general] # 31 Input/output library [[input.output]](./#input.output) ## 31.8 String-based streams [[string.streams]](string.streams#ostringstream.general) ### 31.8.4 Class template basic_ostringstream [[ostringstream]](ostringstream#general) #### 31.8.4.1 General [ostringstream.general] [🔗](#lib:basic_ostringstream) namespace std {template, class Allocator = allocator>class basic_ostringstream : public basic_ostream {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]](ostringstream.cons "31.8.4.2 Constructors"), constructors basic_ostringstream() : basic_ostringstream(ios_base::out) {}explicit basic_ostringstream(ios_base::openmode which); explicit basic_ostringstream(const basic_string& s, ios_base::openmode which = ios_base::out); basic_ostringstream(ios_base::openmode which, const Allocator& a); explicit basic_ostringstream( basic_string&& s, ios_base::openmode which = ios_base::out); template basic_ostringstream(const basic_string& s, const Allocator& a): basic_ostringstream(s, ios_base::out, a) {}template basic_ostringstream(const basic_string& s, ios_base::openmode which, const Allocator& a); templateexplicit basic_ostringstream(const basic_string& s, ios_base::openmode which = ios_base::out); templateexplicit basic_ostringstream(const T& t, ios_base::openmode which = ios_base::out); template basic_ostringstream(const T& t, const Allocator& a); template basic_ostringstream(const T& t, ios_base::openmode which, const Allocator& a); basic_ostringstream(const basic_ostringstream&) = delete; basic_ostringstream(basic_ostringstream&& rhs); basic_ostringstream& operator=(const basic_ostringstream&) = delete; basic_ostringstream& operator=(basic_ostringstream&& rhs); // [[ostringstream.swap]](ostringstream.swap "31.8.4.3 Swap"), swapvoid swap(basic_ostringstream& rhs); // [[ostringstream.members]](ostringstream.members "31.8.4.4 Member functions"), members basic_stringbuf* rdbuf() const; basic_string str() const &; template basic_string str(const SAlloc& sa) const; basic_string str() &&; basic_string_view view() const noexcept; void str(const basic_string& s); templatevoid str(const basic_string& s); void str(basic_string&& s); templatevoid str(const T& t); private: basic_stringbuf *sb*; // *exposition only*};} [1](#1) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L9325) The classbasic_ostringstream supports writing objects of classbasic_string<​charT, traits, Allocator>[.](#1.sentence-1) It uses abasic_stringbuf object to control the associated storage[.](#1.sentence-2) For the sake of exposition, the maintained data is presented here as: - [(1.1)](#1.1) *sb*, the stringbuf object[.](#1.sentence-3)