namespace std {
template<class charT, class traits = char_traits<charT>,
class Allocator = allocator<charT>>
class basic_istringstream : public basic_istream<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;
basic_istringstream() : basic_istringstream(ios_base::in) {}
explicit basic_istringstream(ios_base::openmode which);
explicit basic_istringstream(
const basic_string<charT, traits, Allocator>& s,
ios_base::openmode which = ios_base::in);
basic_istringstream(ios_base::openmode which, const Allocator& a);
explicit basic_istringstream(
basic_string<charT, traits, Allocator>&& s,
ios_base::openmode which = ios_base::in);
template<class SAlloc>
basic_istringstream(
const basic_string<charT, traits, SAlloc>& s, const Allocator& a)
: basic_istringstream(s, ios_base::in, a) {}
template<class SAlloc>
basic_istringstream(
const basic_string<charT, traits, SAlloc>& s,
ios_base::openmode which, const Allocator& a);
template<class SAlloc>
explicit basic_istringstream(
const basic_string<charT, traits, SAlloc>& s,
ios_base::openmode which = ios_base::in);
basic_istringstream(const basic_istringstream&) = delete;
basic_istringstream(basic_istringstream&& rhs);
basic_istringstream& operator=(const basic_istringstream&) = delete;
basic_istringstream& operator=(basic_istringstream&& rhs);
void swap(basic_istringstream& rhs);
basic_stringbuf<charT, traits, Allocator>* rdbuf() const;
basic_string<charT, traits, Allocator> str() const &;
template<class SAlloc>
basic_string<charT,traits,SAlloc> str(const SAlloc& sa) const;
basic_string<charT, traits, Allocator> str() &&;
basic_string_view<charT, traits> view() const noexcept;
void str(const basic_string<charT, traits, Allocator>& s);
template<class SAlloc>
void str(const basic_string<charT, traits, SAlloc>& s);
void str(basic_string<charT, traits, Allocator>&& s);
private:
basic_stringbuf<charT, traits, Allocator> sb;
};
template<class charT, class traits, class Allocator>
void swap(basic_istringstream<charT, traits, Allocator>& x,
basic_istringstream<charT, traits, Allocator>& y);
}
The class
basic_istringstream<charT, traits, Allocator>
supports reading objects of class
basic_string<charT, traits, Allocator>. It uses a
basic_stringbuf<charT, traits, Allocator>
object to control the associated storage
. For the sake of exposition, the maintained data is presented here as:
- sb, the stringbuf object.
explicit basic_istringstream(ios_base::openmode which);
Effects:
Initializes the base class with
basic_istream<charT, traits>(addressof(sb)) (
[istream])
and
sb with
basic_stringbuf<charT, traits, Allocator>(which | ios_base::in) (
[stringbuf.cons])
. explicit basic_istringstream(
const basic_string<charT, traits, Allocator>& s,
ios_base::openmode which = ios_base::in);
Effects:
Initializes the base class with
basic_istream<charT, traits>(addressof(sb)) (
[istream])
and
sb with
basic_stringbuf<charT, traits, Allocator>(s, which | ios_base::in)(
[stringbuf.cons])
. basic_istringstream(ios_base::openmode which, const Allocator& a);
Effects:
Initializes the base class with
basic_istream<charT, traits>(addressof(sb)) (
[istream])
and
sb with
basic_stringbuf<charT, traits, Allocator>(which | ios_base::in, a) (
[stringbuf.cons])
. explicit basic_istringstream(
basic_string<charT, traits, Allocator>&& s,
ios_base::openmode which = ios_base::in);
Effects:
Initializes the base class with
basic_istream<charT, traits>(addressof(sb)) (
[istream])
and
sb with
basic_stringbuf<charT, traits, Allocator>(std::move(s), which | ios_base::in) (
[stringbuf.cons])
. template<class SAlloc>
basic_istringstream(
const basic_string<charT, traits, SAlloc>& s,
ios_base::openmode which, const Allocator& a);
Effects:
Initializes the base class with
basic_istream<charT, traits>(addressof(sb)) (
[istream])
and
sb with
basic_stringbuf<charT, traits, Allocator>(s, which | ios_base::in, a)(
[stringbuf.cons])
. template<class SAlloc>
explicit basic_istringstream(
const basic_string<charT, traits, SAlloc>& s,
ios_base::openmode which = ios_base::in);
Effects:
Initializes the base class with
basic_istream<charT, traits>(addressof(sb)) (
[istream])
and
sb with
basic_stringbuf<charT, traits, Allocator>(s, which | ios_base::in) (
[stringbuf.cons])
. basic_istringstream(basic_istringstream&& rhs);
Effects:
Move constructs from the rvalue
rhs. This
is accomplished by move constructing the base class, and the contained
basic_stringbuf. Then calls
basic_istream<charT, traits>::set_rdbuf(addressof(sb))
to install the contained
basic_stringbuf.void swap(basic_istringstream& rhs);
Effects:
Equivalent to:
basic_istream<charT, traits>::swap(rhs);
sb.swap(rhs.sb);
template<class charT, class traits, class Allocator>
void swap(basic_istringstream<charT, traits, Allocator>& x,
basic_istringstream<charT, traits, Allocator>& y);
Effects:
Equivalent to:
x.swap(y). basic_stringbuf<charT, traits, Allocator>* rdbuf() const;
Returns:
const_cast<basic_stringbuf<charT, traits, Allocator>*>(addressof(sb)). basic_string<charT, traits, Allocator> str() const &;
Effects:
Equivalent to: return rdbuf()->str();
template<class SAlloc>
basic_string<charT,traits,SAlloc> str(const SAlloc& sa) const;
Effects:
Equivalent to: return rdbuf()->str(sa);
basic_string<charT,traits,Allocator> str() &&;
Effects:
Equivalent to: return std::move(*rdbuf()).str();
basic_string_view<charT, traits> view() const noexcept;
Effects:
Equivalent to: return rdbuf()->view();
void str(const basic_string<charT, traits, Allocator>& s);
Effects:
Equivalent to: rdbuf()->str(s);
template<class SAlloc>
void str(const basic_string<charT, traits, SAlloc>& s);
Effects:
Equivalent to: rdbuf()->str(s);
void str(basic_string<charT, traits, Allocator>&& s);
Effects:
Equivalent to: rdbuf()->str(std::move(s));