std::basic_istream::operator>>
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& operator>>( short& value ); basic_istream& operator>>( unsigned short& value ); |
(1) | |
basic_istream& operator>>( int& value ); basic_istream& operator>>( unsigned int& value ); |
(2) | |
basic_istream& operator>>( long& value ); basic_istream& operator>>( unsigned long& value ); |
(3) | |
basic_istream& operator>>( long long& value ); basic_istream& operator>>( unsigned long long& value ); |
(4) | (depuis C++11) |
basic_istream& operator>>( float& value ); basic_istream& operator>>( double& value ); basic_istream& operator>>( long double& value ); |
(5) | |
basic_istream& operator>>( bool& value ); |
(6) | |
basic_istream& operator>>( void*& value ); |
(7) | |
basic_istream& operator>>( basic_istream& st, std::ios_base& (*func)(std::ios_base&) ); basic_istream& operator>>( basic_istream& st, std::basic_ios<CharT,Traits>& (*func)(std::basic_ios<CharT,Traits>&) ); basic_istream& operator>>( basic_istream& st, std::basic_istream& (*func)(std::basic_istream&) ); |
(8) | |
basic_istream& operator>>( basic_istream& st, std::basic_streambuf<CharT,Traits>* sb ); |
(9) | |
1-4)
Extrait une valeur entière en appelant num_get::get()
Original:
Extracts an integer value by calling num_get::get()
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.
5)
Extrait une valeur à virgule flottante en appelant num_get::get()
Original:
Extracts a floating point value by calling num_get::get()
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.
6)
Extraits
bool valeur en appelant num_get::get()Original:
Extracts
bool value by calling num_get::get()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.
7)
Extrait une valeur de pointeur générique en appelant num_get::get()
Original:
Extracts a generic pointer value by calling num_get::get()
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.
8)
Appels
func(*this);, où func est un manipulateur I / O .Original:
Calls
func(*this);, where func is an I/O manipulator.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.
9)
Se comporte comme un
UnformattedInputFunction. Après la construction et la vérification de l'objet sentinelle, extrait toutes les données du flux d'entrée et la stocke dans sb. L'extraction s'arrête lorsque l'une des conditions suivantes sont respectées:Original:
Behaves as an
UnformattedInputFunction. After constructing and checking the sentry object, extracts all data from the input stream and stores it to sb. The extraction stops if one of the following conditions are met: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.
- de fin de fichier se produit sur la séquence d'entrée;Original:end-of-file occurs on the input sequence;The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions. - l'insertion, dans la séquence de sortie échoue (dans ce cas, le caractère d'être ajouté n'est pas extrait);Original:inserting in the output sequence fails (in which case the character to be inserted is not extracted);The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions. - une exception se produit (dans ce cas, l'exception est interceptée) .Original:an exception occurs (in which case the exception is caught).The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Dans les deux cas, stocke le nombre de caractères extraits dans la variable membre accessibles par des appels ultérieurs à
gcount() Original:
In either case, stores the number of characters extracted in the member variable accessed by subsequent calls to
gcount() 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.
Notes
Les versions (1-7) de l'opérateur se comporte comme' fonctions d'entrée formatées. Autrement dit, ils construisent un objet
sentry au début que les bouffées de la cravate () 'd tampons si nécessaire, vérifie les erreurs et les extraits et les rejets tous les protagonistes blancs à moins que le drapeau ios_base :: skipws a été effacé. L'entrée est tentée uniquement si l'objet sentry retourne true .Original:
The (1-7) versions of the operator behave as formatted input functions. That is, they construct a
sentry object at the beginning that flushes the tie()'d buffers if needed, checks for errors, and extracts and discards all leading whitespace characters unless the ios_base::skipws flag was cleared. The input is attempted only if the sentry object returns true.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.
La version 8) ne construit pas l'objet sentinelle. La version 9) construit un objet sentinelle avec
noskipws mis à true .Original:
The version 8) does not construct the sentry object. The version 9) constructs a sentry object with
noskipws set to true.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 l'extraction échoue (par exemple, si une lettre a été introduit lorsque un chiffre est attendu),
value n'est pas modifié et failbit est (avant C++11)Original:
If extraction fails (e.g. if a letter was entered where a digit is expected),
value is left unmodified and failbit is set (avant C++11)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 l'extraction échoue, le zéro est écrit
value et failbit est réglé. Si les résultats de l'extraction de la valeur trop grande ou trop petite pour tenir dans value, std::numeric_limits<T>::max() ou std::numeric_limits<T>::min() est écrit et le drapeau failbit est réglé. (depuis C++11)Original:
If extraction fails, zero is written to
value and failbit is set. If extraction results in the value too large or too small to fit in value, std::numeric_limits<T>::max() or std::numeric_limits<T>::min() is written and failbit flag is set. (depuis C++11)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
| value | - | référence à une valeur de nombre entier ou à virgule flottante pour stocker la valeur extraite de
Original: reference to an integer or floating-point value to store the extracted value to The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. |
| func | - | pointeur de fonction de manipulateur d'E / S
Original: pointer to I/O manipulator function The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. |
| sb | - | pointeur vers le streambuffer d'écrire toutes les données
Original: pointer to the streambuffer to write all the data to The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. |
Retourne la valeur
*this
Exemple
#include <iostream>
#include <iomanip>
#include <sstream>
int main()
{
std::string input = "41 3.14 false hello world";
std::istringstream stream(input);
int n;
double f;
bool b;
stream >> n >> f >> std::boolalpha >> b;
std::cout << "n = " << n << '\n'
<< "f = " << f << '\n'
<< "b = " << std::boolalpha << b << '\n';
// extract the rest using the streambuf overload
stream >> std::cout.rdbuf();
std::cout << '\n';
}
Résultat :
n = 41
f = 3.14
b = false
hello world
Voir aussi
extrait des tableaux de caractères et de caractères Original: extracts characters and character arrays The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (fonction générique) | |
effectue flux d'E / S de chaînes Original: performs stream I/O of strings The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (fonction générique) | |
effectue flux d'entrée et de sortie de bitsets Original: performs stream input and output of bitsets The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (fonction) | |
sérialise et désérialise un nombre complexe Original: serializes and deserializes a complex number The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (fonction générique) | |
effectue flux d'entrée et de sortie sur le moteur de nombres pseudo-aléatoires Original: performs stream input and output on pseudo-random number engine The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (fonction) | |
effectue flux d'entrée et de sortie sur la distribution de nombre pseudo-aléatoire Original: performs stream input and output on pseudo-random number distribution The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (fonction) | |
extrait des blocs de caractères Original: extracts blocks of characters 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) | |
extrait des blocs déjà disponibles de caractères Original: extracts already available blocks of characters 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) | |
extraits caractères Original: extracts characters 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) | |
caractères extraits jusqu'à ce que le caractère donné se trouve Original: extracts characters until the given character is found 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) | |