Namensräume
Varianten
Aktionen

std::basic_ios::operator bool

Aus cppreference.com
< cpp‎ | io‎ | basic ios

 
 
Input / Output-Bibliothek
I / O-Manipulatoren
C-style I / O
Puffern
Original:
Buffers
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
basic_streambuf
basic_filebuf
basic_stringbuf
strstreambuf(veraltet)
Streams
Original:
Streams
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Abstraktionen
Original:
Abstractions
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
ios_base
basic_ios
basic_istream
basic_ostream
basic_iostream
Datei-I / O
Original:
File I/O
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
basic_ifstream
basic_ofstream
basic_fstream
String I / O
Original:
String I/O
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
basic_istringstream
basic_ostringstream
basic_stringstream
Array I / O
Original:
Array I/O
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
istrstream(veraltet)
ostrstream(veraltet)
strstream(veraltet)
Types
Original:
Types
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
streamoff
streamsize
fpos
Fehler Kategorie Schnittstelle
Original:
Error category interface
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
iostream_category(C++11)
io_errc(C++11)
 
std::basic_ios
Member-Funktionen
Original:
Member functions
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
basic_ios::basic_ios
basic_ios::~basic_ios
Funktionen des Staates
Original:
State functions
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
basic_ios::good
basic_ios::eof
basic_ios::fail
basic_ios::bad
basic_ios::operator!
basic_ios::operator bool
basic_ios::rdstate
basic_ios::setstate
basic_ios::clear
Formatierung
Original:
Formatting
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
basic_ios::copyfmt
basic_ios::fill
Verschiedenes
Original:
Miscellaneous
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
basic_ios::exceptions
basic_ios::imbue
basic_ios::rdbuf
basic_ios::tie
basic_ios::narrow
basic_ios::widen
Geschützt Member-Funktionen
Original:
Protected member functions
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
basic_ios::init
basic_ios::move
basic_ios::swap
basic_ios::set_rdbuf
 
operator void*() const;
(1) (bis C + +11)
explicit operator bool() const;
(2) (seit C++11)
1)
Gibt eine Null-Zeiger, wenn fail() kehrt true, sonst gibt einen Nicht-Null-Zeiger. Dieser Zeiger ist implizit konvertierbar bool und kann in Booleschen Kontext verwendet werden .
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.
2)
true kehrt, wenn der Stream hat keine Fehler aufgetreten sind und ist bereit von I / O-Operationen. Insbesondere kehrt !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.
Dieser Operator ermöglicht es, Ströme und Funktionen, die Verweise zurück auf Streams als Loop Bedingungen, was in der idiomatischen C + + verwenden Input-Schleifen, wie while(stream >> value) {...} oder while(getline(stream, string)){...}. Solche Schleifen führen der Schleife Körper nur, wenn die Eingabe-Operation gelungen .
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.

Inhaltsverzeichnis

[Bearbeiten] Parameter

(None)
Original:
(none)
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

[Bearbeiten] Rückgabewert

true wenn der Stream hat keine Fehler aufgetreten sind, false sonst .
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.

[Bearbeiten] Beispiel

#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

[Bearbeiten] Siehe auch

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