◐ Shell
clean mode source ↗

std::basic_stringstream::basic_stringstream — cppreference.com

De 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) (depuis C++11)

Construit flux nouvelle chaîne .

Original:

Constructs new string stream.

The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

1)

Construit nouveau dispositif de chaîne sous-jacente. L'objet basic_stringbuf sous-jacente est construit comme basic_stringbuf<Char,Traits,Allocator>(mode).

Original:

Constructs new underlying string device. The underlying basic_stringbuf object is constructed as basic_stringbuf<Char,Traits,Allocator>(mode).

The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

2)

Utilise une copie de str comme contenu initial du dispositif de chaîne sous-jacente. L'objet basic_stringbuf sous-jacente est construit comme basic_stringbuf<Char,Traits,Allocator>(str, mode).

Original:

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

The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

3)

Déplacez constructeur. Construit le flux de fichier avec l'état de other en utilisant la sémantique de déplacement .

Original:

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

The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

Paramètres

str -

Chaîne à utiliser comme contenu initial du flux de chaîne

Original:

string to use as initial contents of the string stream

The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

mode -

spécifie le mode de flux ouvert. Il est de type masque, les constantes suivantes sont définies:

Constante

Original:

Constant

The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

Explanation
app

demander à l'extrémité du flux avant chaque écriture

Original:

seek to the end of stream before each write

The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

binary

ouvrir en mode binaire

Original:

open in binary mode

The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

in

ouvrir en lecture

Original:

open for reading

The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

out

ouvrir en écriture

Original:

open for writing

The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

trunc

jeter le contenu du courant lors de l'ouverture

Original:

discard the contents of the stream when opening

The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

ate

demander à l'extrémité du flux immédiatement après ouverture

Original:

seek to the end of stream immediately after open

The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

Original:

specifies stream open mode. It is bitmask type, the following constants are defined:

Constante

Original:

Constant

The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

Explanation
app

demander à l'extrémité du flux avant chaque écriture

Original:

seek to the end of stream before each write

The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

binary

ouvrir en mode binaire

Original:

open in binary mode

The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

in

ouvrir en lecture

Original:

open for reading

The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

out

ouvrir en écriture

Original:

open for writing

The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

trunc

jeter le contenu du courant lors de l'ouverture

Original:

discard the contents of the stream when opening

The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

ate

demander à l'extrémité du flux immédiatement après ouverture

Original:

seek to the end of stream immediately after open

The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

other -

une autre source de chaîne à utiliser comme source

Original:

another string stream to use as source

The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

Exemple

#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';
}

Résultat :

buf1 = 7 n = 7
n = -10
test1

Voir aussi

obtient ou définit le contenu de l'objet chaîne de périphérique sous-jacent

Original:

gets or sets the contents of underlying string device object

The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.


(fonction membre publique) [edit]

construit un objet basic_stringbuf

Original:

constructs a basic_stringbuf object

The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.


(fonction membre publique de std::basic_stringbuf) [edit]