[istringstream.cons]

# 31 Input/output library [[input.output]](./#input.output)

## 31.8 String-based streams [[string.streams]](string.streams#istringstream.cons)

### 31.8.3 Class template basic_istringstream [[istringstream]](istringstream#cons)

#### 31.8.3.2 Constructors [istringstream.cons]

[ð](#lib:basic_istringstream,constructor)

`explicit basic_istringstream(ios_base::openmode which);
`

[1](#1)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L8975)

*Effects*: Initializes the base class withbasic_istream<charT, traits>(addressof(*sb*)) ([[istream]](istream "31.7.5.2 Class template basic_­istream"))
and *sb* withbasic_stringbuf<charT, traits, Allocator>(which | ios_base​::​in) ([[stringbuf.cons]](stringbuf.cons "31.8.2.2 Constructors"))[.](#1.sentence-1)

[ð](#lib:basic_istringstream,constructor_)

`explicit basic_istringstream(
  const basic_string<charT, traits, Allocator>& s,
  ios_base::openmode which = ios_base::in);
`

[2](#2)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L8991)

*Effects*: Initializes the base class withbasic_istream<charT, traits>(addressof(*sb*)) ([[istream]](istream "31.7.5.2 Class template basic_­istream"))
and *sb* withbasic_stringbuf<charT, traits, Allocator>(s, which | ios_base​::​in)  
 ([[stringbuf.cons]](stringbuf.cons "31.8.2.2 Constructors"))[.](#2.sentence-1)

[ð](#lib:basic_istringstream,constructor__)

`basic_istringstream(ios_base::openmode which, const Allocator& a);
`

[3](#3)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L9005)

*Effects*: Initializes the base class withbasic_istream<charT, traits>(addressof(*sb*)) ([[istream]](istream "31.7.5.2 Class template basic_­istream"))
and *sb* withbasic_stringbuf<charT, traits, Allocator>(which | ios_base​::​in, a) ([[stringbuf.cons]](stringbuf.cons "31.8.2.2 Constructors"))[.](#3.sentence-1)

[ð](#lib:basic_istringstream,constructor___)

`explicit basic_istringstream(
  basic_string<charT, traits, Allocator>&& s,
  ios_base::openmode which = ios_base::in);
`

[4](#4)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L9021)

*Effects*: Initializes the base class withbasic_istream<charT, traits>(addressof(*sb*)) ([[istream]](istream "31.7.5.2 Class template basic_­istream"))
and *sb* withbasic_stringbuf<charT, traits, Allocator>(std​::​move(s), which | ios_base​::​​in) ([[stringbuf.cons]](stringbuf.cons "31.8.2.2 Constructors"))[.](#4.sentence-1)

[ð](#lib:basic_istringstream,constructor____)

`template<class SAlloc>
  basic_istringstream(
    const basic_string<charT, traits, SAlloc>& s,
    ios_base::openmode which, const Allocator& a);
`

[5](#5)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L9038)

*Effects*: Initializes the base class withbasic_istream<charT, traits>(addressof(*sb*)) ([[istream]](istream "31.7.5.2 Class template basic_­istream"))
and *sb* withbasic_stringbuf<charT, traits, Allocator>(s, which | ios_base​::​in, a)  
 ([[stringbuf.cons]](stringbuf.cons "31.8.2.2 Constructors"))[.](#5.sentence-1)

[ð](#lib:basic_istringstream,constructor_____)

`template<class SAlloc>
  explicit basic_istringstream(
    const basic_string<charT, traits, SAlloc>& s,
    ios_base::openmode which = ios_base::in);
`

[6](#6)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L9055)

*Constraints*: is_same_v<SAlloc, Allocator> is false[.](#6.sentence-1)

[7](#7)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L9059)

*Effects*: Initializes the base class withbasic_istream<charT, traits>(addressof(*sb*)) ([[istream]](istream "31.7.5.2 Class template basic_­istream"))
and *sb* withbasic_stringbuf<charT, traits, Allocator>(s, which | ios_base​::​in) ([[stringbuf.cons]](stringbuf.cons "31.8.2.2 Constructors"))[.](#7.sentence-1)

[ð](#lib:basic_istringstream,constructor______)

`template<class T>
  explicit basic_istringstream(const T& t, ios_base::openmode which = ios_base::in);
template<class T>
  basic_istringstream(const T& t, const Allocator& a);
template<class T>
  basic_istringstream(const T& t, ios_base::openmode which, const Allocator& a);
`

[8](#8)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L9078)

Let which be ios_base​::​in 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#L9083)

*Constraints*: is_convertible_v<const T&, basic_string_view<charT, traits>> is true[.](#9.sentence-1)

[10](#10)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L9088)

*Effects*: Initializes the base class with addressof(*sb*), and
direct-non-list-initializes *sb* with t, which | ios_base​::​in, a[.](#10.sentence-1)

[ð](#lib:basic_istringstream,constructor_______)

`basic_istringstream(basic_istringstream&& rhs);
`

[11](#11)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L9100)

*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_istream<charT, traits>​::​set_rdbuf(addressof(*sb*)) to install the contained basic_stringbuf[.](#11.sentence-3)
