std::basic_stringstream::basic_stringstream
cppreference.com
[] |
Google. . , . , . |
<metanoindex/>
<tbody> </tbody> basic_stringstream( ios_base::openmode mode = ios_base::in|ios_base::out ); |
(1) | |
basic_stringstream( const std::basic_string<CharT,Traits,Allocator>& str, {{#pad:|18}} ios_base::openmode mode = ios_base::in|ios_base::out ); |
(2) | |
basic_stringstream( basic_stringstream&& other ); |
(3) | ( C++11) |
.
1)
.
basic_stringbuf basic_stringbuf<Char,Traits,Allocator>(mode).:
Constructs new underlying string device. The underlying
basic_stringbuf object is constructed as basic_stringbuf<Char,Traits,Allocator>(mode).2)
str . basic_stringbuf basic_stringbuf<Char,Traits,Allocator>(str, mode).:
Uses a copy of
str as initial contents of the underlying string device. The underlying basic_stringbuf object is constructed as basic_stringbuf<Char,Traits,Allocator>(str, mode).3)
.
other . :
Move constructor. Constructs the file stream with the state of
other using move semantics. | str | ,
| |
| mode | ||
| other |
#include <iostream>
#include <sstream>
int main()
{
// default constructor (input/output stream)
std::stringstream buf1;
buf1 << 7;
int n = 0;
buf1 >> n;
std::cout << "buf1 = " << buf1.str() << " n = " << n << '\n';
// input stream
std::istringstream inbuf("-10");
inbuf >> n;
std::cout << "n = " << n << '\n';
// output stream in append mode (C++11)
std::ostringstream buf2("test", std::ios_base::ate);
buf2 << '1';
std::cout << buf2.str() << '\n';
}
:
buf1 = 7 n = 7
n = -10
test1
.
(public -) | |
basic_stringbuf (public - std::basic_stringbuf)
|