std::basic_ios::operator bool
Da cppreference.com.
![]() |
Questa pagina è stata tradotta in modo automatico dalla versione in ineglese della wiki usando Google Translate.
La traduzione potrebbe contenere errori e termini strani. Muovi il puntatore sopra al testo per vedere la versione originale. Puoi aiutarci a correggere gli gli errori. Per ulteriori istruzioni clicca qui. |
operator void*() const; |
(1) | (fino al c++11) |
explicit operator bool() const; |
(2) | (dal C++11) |
Restituisce un puntatore nullo se fail() ritorna true, altrimenti restituisce un valore non null pointer. Questo puntatore è convertibile in modo implicito bool e può essere utilizzato in un contesto 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.
Restituisce true se il flusso non ci sono errori commessi ed è pronto di operazioni di I / O. In particolare, torna !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.
Questo operatore permette di utilizzare i flussi e funzioni che restituiscono riferimenti a flussi come condizioni di ciclo, con conseguente idiomatica C + + ingresso cicli come while(stream >> value) {...} o while(getline(stream, string)){...}. Tali cicli di eseguire il corpo del ciclo solo se l'operazione è riuscita ingresso.
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.
Indice |
[modifica] Parametri
(Nessuno)
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.
[modifica] Valore di ritorno
true se il flusso è non si sono verificati errori, false altrimenti.
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.
[modifica] Esempio
#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
[modifica] Vedi anche
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 |