std::basic_ios::operator bool
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. |
| operator void*() const; |
(1) | (hasta C + +11) |
| explicit operator bool() const; |
(2) | (ya que C + +11) |
Devuelve un puntero nulo si fail() vuelve true lo contrario, devuelve un puntero no nulo. Este puntero es implícitamente convertible a bool y puede ser utilizado en el contexto booleano .
2) Original:
Returns a null pointer if fail() returns true, otherwise returns a non-null pointer. This pointer is implicitly convertible to bool and may be used in boolean context.
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.
Devoluciones true si la corriente no tiene errores ocurridos y está listo de las operaciones de E / S. En concreto, devoluciones !fail() .
Original:
Returns true if the stream has no errors occurred and is ready of I/O operations. Specifically, returns !fail().
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.
Este operador hace que sea posible utilizar secuencias y funciones que devuelven referencias a corrientes como condiciones de bucle, lo que resulta en la idiomático C + + de entrada de bucles tales como while(stream >> value) {...} o while(getline(stream, string)){...}. Dichos bucles ejecutar el cuerpo del bucle sólo si la operación tuvo éxito entrada .
Original:
This operator makes it possible to use streams and functions that return references to streams as loop conditions, resulting in the idiomatic C++ input loops such as while(stream >> value) {...} or while(getline(stream, string)){...}. Such loops execute the loop's body only if the input operation succeeded.
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] Parámetros
(Ninguno)
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.
[editar] Valor de retorno
true si la transferencia se no han ocurrido errores, false de otra manera .
Original:
true if the stream has no errors occurred, false otherwise.
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] Ejemplo
#include <iostream> #include <sstream> int main() { std::istringstream s("1 2 3 error"); int n; std::cout << std::boolalpha << "(bool)s is " << (bool)s << '\n'; while (s >> n) { std::cout << n << '\n'; } std::cout << std::boolalpha << "(bool)s is " << (bool)s << '\n'; }
Output:
(bool)s is true 1 2 3 (bool)s is false
[editar] Ver también
| ios_base::iostate flags | basic_ios accessors | |||||||
| eofbit | failbit | badbit | good() | fail() | bad() | eof() | operator bool() | operator!() |
| false | false | false | true | false | false | false | true | false |
| false | false | true | false | true | true | false | false | true |
| false | true | false | false | true | false | false | false | true |
| false | true | true | false | true | true | false | false | true |
| true | false | false | false | false | false | true | true | false |
| true | false | true | false | true | true | true | false | true |
| true | true | false | false | true | false | true | false | true |
| true | true | true | false | true | true | true | false | true |