std::basic_istream::operator>>
De cppreference.com
< cpp | io | basic istream
![]() | Esta página se ha traducido por ordenador/computador/computadora de la versión en inglés de la Wiki usando Google Translate. La traducción puede contener errores y palabras aparatosas/incorrectas. Planea sobre el texto para ver la versión original. Puedes ayudar a corregir los errores y mejorar la traducción. Para instrucciones haz clic aquí. |
basic_istream& operator>>(short& value ); basic_istream& operator>>(unsignedshort& value ); | (1) | |
basic_istream& operator>>(int& value ); basic_istream& operator>>(unsignedint& value ); | (2) | |
basic_istream& operator>>(long& value ); basic_istream& operator>>(unsignedlong& value ); | (3) | |
basic_istream& operator>>(longlong& value ); basic_istream& operator>>(unsignedlonglong& value ); | (4) | (desde C++11) |
basic_istream& operator>>(float& value ); basic_istream& operator>>(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&)); | (8) | |
basic_istream& operator>>( basic_istream& st, std::basic_streambuf<CharT,Traits>* sb ); | (9) | |
Extractos un valor entero llamando num_get::get()
5) 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.
Extrae un valor de punto flotante llamando num_get::get()
6) 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.
Extractos bool valor llamando num_get::get()
7) 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.
Extrae un valor de puntero genérico llamando num_get::get()
8) 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.
Pide func(*this);, donde
9) func
es un manipulador 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.
Se comporta como un
UnformattedInputFunction
. Después de la construcción y comprobación del objeto centinela, extrae todos los datos del flujo de entrada y lo almacena en sb
. La extracción se detiene si una de las condiciones siguientes: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 archivo se produce en la secuencia de entrada;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. - insertar en la secuencia de salida de falla (en cuyo caso el carácter a ser insertado no se extrae);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. - se produce una excepción (en cuyo caso se detecta la excepción) .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.
En cualquier caso, almacena el número de caracteres extraídos en la variable miembro visitada por llamadas posteriores a
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.
Contenido |
[editar]Notas
Las versiones (1-7) del operador se comportan como funciones de entrada formateados'. Es decir, construir un objeto
sentry
al principio que vacía el empate () 'd tampones si es necesario, el control de errores, así como extractos y descarta todos los principales espacios en blanco a menos que la bandera ios_base :: skipws fue absuelto. La entrada se trató sólo si el objeto sentry
devuelve 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 versión 8) no construye el objeto centinela. La versión 9) construye un objeto centinela con
noskipws
establecido en 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 la extracción falla (por ejemplo, si una carta donde se ha introducido un dígito se esperaba),
value
se deja sin modificar y failbit
se establece (hasta 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 (hasta 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 la extracción falla, cero se escribe en
value
y failbit
establece. Si los resultados de extracción en un valor demasiado grande o demasiado pequeño para caber en value
, std::numeric_limits<T>::max() o std::numeric_limits<T>::min() está escrito y la bandera failbit
establece. (desde 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. (desde 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.
[editar]Parámetros
value | - | referencia a un valor entero o de punto flotante para almacenar el valor extraído 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 | - | puntero a I / O función manipulador 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 | - | puntero a la streambuffer a escribir todos los datos 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. |
[editar]Valor de retorno
*this
[editar]Ejemplo
Ejecuta este código
#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';}
Salida:
n = 41 f = 3.14 b = false hello world
[editar]Ver también
extrae caracteres y matrices de caracteres (plantilla de función) | |
realiza secuencia de E / S de cadenas 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. (plantilla de función) | |
realiza flujo de entrada y salida 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. (función) | |
serializa y deserializa un número complejo 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. (plantilla de función) | |
realiza flujo de entrada y de salida en el motor de números pseudo-aleatorios (función) | |
realiza flujo de entrada y salida en la distribución de números pseudo-aleatorios (función) | |
extrae los bloques de caracteres 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. (función miembro pública) | |
extrae los bloques que ya están disponibles los personajes 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. (función miembro pública) | |
Extrae caracteres. (función miembro pública) | |
Extrae caracteres hasta que se encuentra el carácter dado. (función miembro pública) |