std::basic_istream::putback
De cppreference.com
|
|
This page has been machine-translated from the English version of the wiki using Google Translate.
The translation may contain errors and awkward wording. Hover over text to see the original version. You can help to fix errors and improve the translation. For instructions click here. |
<metanoindex/>
<tbody> </tbody> basic_istream& putback( char_type ch ); |
||
Met le caractère
ch dans le flux d'entrée de sorte que le caractère suivant extrait sera ch . Original:
Puts the character
ch back to the input stream so the next extracted character will be ch. The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
Première efface
eofbit, puis se comporte comme UnformattedInputFunction. Après la construction et la vérification de l'objet sentinelle, si rdbuf() n'est pas nulle, appelle rdbuf()->sputbackc(ch), qui appelle rdbuf()->pbackfail(ch) si ch n'égale pas le personnage le plus récemment extraite .Original:
First clears
eofbit, then behaves as UnformattedInputFunction. After constructing and checking the sentry object, if rdbuf() is not null, calls rdbuf()->sputbackc(ch), which calls rdbuf()->pbackfail(ch) if ch does not equal the most recently extracted character.The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
Si
rdbuf() est nul ou si rdbuf->sputbackc(ch) retours Traits::eof(), appelle setstate(badbit) .Original:
If
rdbuf() is null or if rdbuf->sputbackc(ch) returns Traits::eof(), calls setstate(badbit).The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
Dans tous les cas, fixe la
gcount() compteur à zéro .Original:
In any case, sets the
gcount() counter to zero.The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
Paramètres
(Aucun)
Original:
(none)
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
Retourne la valeur
*this
Exemple
montre la différence entre la modification et non-modification putback ()
Original:
demonstrates the difference between modifying and non-modifying putback()
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
#include <sstream>
#include <iostream>
int main()
{
std::stringstream s1("Hello, world"); // IO stream
s1.get();
if(s1.putback('Y')) // modifies the buffer
std::cout << s1.rdbuf() << '\n';
else
std::cout << "putback failed\n";
std::istringstream s2("Hello, world"); // input-only stream
s2.get();
if(s2.putback('Y')) // cannot modify input-only buffer
std::cout << s2.rdbuf() << '\n';
else
std::cout << "putback failed\n";
s2.clear();
if(s2.putback('H')) // non-modifying putback
std::cout << s2.rdbuf() << '\n';
else
std::cout << "putback failed\n";
}
Résultat :
Yello, world
putback failed
Hello, world
Voir aussi
unextracts un caractère Original: unextracts a character 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) | |
lit le caractère suivant sans l'extraire Original: reads the next character without extracting it 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) | |