[ Web Proxy ]
URL:
Viewing: http://ru.cppreference.com/cpp/io/basic_stringstream/basic_stringstream [Back]  [Original]

std::basic_stringstream::basic_stringstream cppreference.com
cppreference.com

std::basic_stringstream::basic_stringstream

cppreference.com

<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)
.
:
Constructs new string stream.
Google.
. .

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).
Google.
. .

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).
Google.
. .

3)

. other .
:
Move constructor. Constructs the file stream with the state of other using move semantics.
Google.
. .

str
,
:
string to use as initial contents of the string stream
Google.
. .
mode
. , :
app
binary
in
out
trunc
ate
noreplace (C++23)
:
specifies stream open mode. It is bitmask type, the following constants are defined:
app
binary
in
out
trunc
ate
noreplace (C++23)
Google.
. .
other
:
another string stream to use as source
Google.
. .

#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

.

:
gets or sets the contents of underlying string device object
Google.
. .

(public -) []
basic_stringbuf
:
constructs a basic_stringbuf object
Google.
. .

(public - std::basic_stringbuf) []

Web Proxy Viewer  |  New URL  |  Original Page