[ostringstream.cons] # 31 Input/output library [[input.output]](./#input.output) ## 31.8 String-based streams [[string.streams]](string.streams#ostringstream.cons) ### 31.8.4 Class template basic_ostringstream [[ostringstream]](ostringstream#cons) #### 31.8.4.2 Constructors [ostringstream.cons] [🔗](#lib:basic_ostringstream,constructor) `explicit basic_ostringstream(ios_base::openmode which); ` [1](#1) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L9347) *Effects*: Initializes the base class withbasic_ostream(addressof(*sb*)) ([[ostream]](ostream "31.7.6.2 Class template basic_­ostream")) and *sb* withbasic_stringbuf(which | ios_base​::​out) ([[stringbuf.cons]](stringbuf.cons "31.8.2.2 Constructors"))[.](#1.sentence-1) [🔗](#lib:basic_ostringstream,constructor_) `explicit basic_ostringstream( const basic_string& s, ios_base::openmode which = ios_base::out); ` [2](#2) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L9363) *Effects*: Initializes the base class withbasic_ostream(addressof(*sb*)) ([[ostream]](ostream "31.7.6.2 Class template basic_­ostream")) and *sb* withbasic_stringbuf(s, which | ios_base​::​out) ([[stringbuf.cons]](stringbuf.cons "31.8.2.2 Constructors"))[.](#2.sentence-1) [🔗](#lib:basic_ostringstream,constructor__) `basic_ostringstream(ios_base::openmode which, const Allocator& a); ` [3](#3) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L9377) *Effects*: Initializes the base class withbasic_ostream(addressof(*sb*)) ([[ostream]](ostream "31.7.6.2 Class template basic_­ostream")) and *sb* withbasic_stringbuf(which | ios_base​::​out, a) ([[stringbuf.cons]](stringbuf.cons "31.8.2.2 Constructors"))[.](#3.sentence-1) [🔗](#lib:basic_ostringstream,constructor___) `explicit basic_ostringstream( basic_string&& s, ios_base::openmode which = ios_base::out); ` [4](#4) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L9393) *Effects*: Initializes the base class withbasic_ostream(addressof(*sb*)) ([[ostream]](ostream "31.7.6.2 Class template basic_­ostream")) and *sb* withbasic_stringbuf(std​::​move(s), which | ios_base​::​​out) ([[stringbuf.cons]](stringbuf.cons "31.8.2.2 Constructors"))[.](#4.sentence-1) [🔗](#lib:basic_ostringstream,constructor____) `template basic_ostringstream( const basic_string& s, ios_base::openmode which, const Allocator& a); ` [5](#5) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L9410) *Effects*: Initializes the base class withbasic_ostream(addressof(*sb*)) ([[ostream]](ostream "31.7.6.2 Class template basic_­ostream")) and *sb* withbasic_stringbuf(s, which | ios_base​::​out, a) ([[stringbuf.cons]](stringbuf.cons "31.8.2.2 Constructors"))[.](#5.sentence-1) [🔗](#lib:basic_ostringstream,constructor_____) `template explicit basic_ostringstream( const basic_string& s, ios_base::openmode which = ios_base::out); ` [6](#6) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L9427) *Constraints*: is_same_v is false[.](#6.sentence-1) [7](#7) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L9431) *Effects*: Initializes the base class withbasic_ostream(addressof(*sb*)) ([[ostream]](ostream "31.7.6.2 Class template basic_­ostream")) and *sb* withbasic_stringbuf(s, which | ios_base​::​out) ([[stringbuf.cons]](stringbuf.cons "31.8.2.2 Constructors"))[.](#7.sentence-1) [🔗](#lib:basic_ostringstream,constructor______) `template explicit 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); ` [8](#8) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L9450) Let which be ios_base​::​out for the overload with no parameter which, anda be Allocator() for the overload with no parameter a[.](#8.sentence-1) [9](#9) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L9455) *Constraints*: is_convertible_v> is true[.](#9.sentence-1) [10](#10) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L9460) *Effects*: Initializes the base class with addressof(*sb*), and direct-non-list-initializes *sb* with t, which | ios_base​::​out, a[.](#10.sentence-1) [🔗](#lib:basic_ostringstream,constructor_______) `basic_ostringstream(basic_ostringstream&& rhs); ` [11](#11) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L9472) *Effects*: Move constructs from the rvalue rhs[.](#11.sentence-1) This is accomplished by move constructing the base class, and the containedbasic_stringbuf[.](#11.sentence-2) Then calls basic_ostream​::​set_rdbuf(addressof(*sb*)) to install the contained basic_stringbuf[.](#11.sentence-3)