namespace std { template <class charT, class traits = char_traits<charT>, class Allocator = allocator<charT>> class basic_stringstream : public basic_iostream<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; // [stringstream.cons], constructors explicit basic_stringstream( ios_base::openmode which = ios_base::out | ios_base::in); explicit basic_stringstream( const basic_string<charT, traits, Allocator>& str, ios_base::openmode which = ios_base::out | ios_base::in); basic_stringstream(const basic_stringstream& rhs) = delete; basic_stringstream(basic_stringstream&& rhs); // [stringstream.assign], assign and swap basic_stringstream& operator=(const basic_stringstream& rhs) = delete; basic_stringstream& operator=(basic_stringstream&& rhs); void swap(basic_stringstream& rhs); // [stringstream.members], members basic_stringbuf<charT, traits, Allocator>* rdbuf() const; basic_string<charT, traits, Allocator> str() const; void str(const basic_string<charT, traits, Allocator>& str); private: basic_stringbuf<charT, traits> sb; // exposition only }; template <class charT, class traits, class Allocator> void swap(basic_stringstream<charT, traits, Allocator>& x, basic_stringstream<charT, traits, Allocator>& y); }
Шаблон класса basic_stringstream<charT, traits> поддерживает чтение и запись из объектов класса basic_string<charT, traits, Allocator>. Он использует basic_stringbuf<charT, traits, Allocator> объект для управления связанной последовательностью. Для наглядности сохраненные данные представлены здесь как
sb, stringbuf объект.
explicit basic_stringstream(
ios_base::openmode which = ios_base::out | ios_base::in);
Effects: Создает объект класса basic_stringstream<charT, traits>, инициализируя базовый класс basic_iostream(&sb) и инициализируя sb с помощью basic_stringbuf<charT, traits, Allocator>(which).
explicit basic_stringstream(
const basic_string<charT, traits, Allocator>& str,
ios_base::openmode which = ios_base::out | ios_base::in);
Effects: Создает объект класса basic_stringstream<charT, traits>, инициализируя базовый класс basic_iostream(&sb) и инициализируя sb с помощью basic_stringbuf<charT, traits, Allocator>(str, which).
basic_stringstream(basic_stringstream&& rhs);
basic_stringstream& operator=(basic_stringstream&& rhs);
void swap(basic_stringstream& rhs);
Effects: Меняет состояние *this и rhs по вызову basic_iostream<charT,traits>::swap(rhs) и sb.swap(rhs.sb).
template <class charT, class traits, class Allocator>
void swap(basic_stringstream<charT, traits, Allocator>& x,
basic_stringstream<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>& str);