std::operator<<,>>
Aus cppreference.com
< cpp | string | basic string
![]() | 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. |
definiert in Header <string> | ||
template<class CharT, class Traits, class Allocator> std::basic_ostream<CharT, Traits>& | (1) | |
template<class CharT, class Traits, class Allocator> std::basic_istream<CharT, Traits>& | (2) | |
Zunächst baut eine std::basic_ostream::sentry Objekt, welches spült die Krawatte () 'd Stream falls nötig und Fehler überprüft. Wenn die Wache Objekt zurückgibt false, sofort beendet .
Original:
First, constructs a std::basic_ostream::sentry object, which flushes the tie()'d stream if necessary and checks for errors. If the sentry object returns false, exits immediately.
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.
Danach, wenn der Posten Objekt zurückkehrt true, bestimmt das Ausgabeformat Polsterung in der gleichen Weise wie die Stufe 3 der num_put::put() .
Original:
Afterwards, if the sentry object returns true, determines the output format padding in the same manner as stage 3 of num_put::put().
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.
Dann speichert jedes Zeichen aus der resultierenden Sequenz (die Inhalte der
str
sowie padding) mit dem Ausgang Stream os
, als ob durch den Aufruf os.rdbuf()->sputn(seq, n), wo n=std::max(os.width(), str.size())Original:
Then stores each character from the resulting sequence (the contents of
str
plus padding) to the output stream os
as if by calling os.rdbuf()->sputn(seq, n), where n=std::max(os.width(), str.size())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.
Schließlich ruft os.width(0) .
2) Original:
Finally, calls os.width(0).
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.
Zunächst baut eine std::basic_istream::sentry Objekt, welches spült die Krawatte () 'd Stream gegebenenfalls Extrakte und verwirft alle führenden Leerzeichen, wenn die ios_base::skipws Flagge wurde gelöscht, und prüft auf Fehler. Wenn die Wache Objekt zurückgibt false, sofort beendet .
Original:
First, constructs a std::basic_istream::sentry object, which flushes the tie()'d stream if necessary, extracts and discards all leading whitespace characters unless the ios_base::skipws flag was cleared, and checks for errors. If the sentry object returns false, exits immediately.
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.
Danach, wenn die Wache Objekt kehrt true, löscht
str
mit str.erase()Original:
Afterwards, if the sentry object returns true, clears
str
with str.erase()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.
Dann liest Zeichen aus
is
und fügt sie str
wie durch str.append(1, c), bis eine der folgenden Bedingungen wahr wird:Original:
Then reads characters from
is
and appends them to str
as if by str.append(1, c), until one of the following conditions becomes 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.
N
Zeichen gelesen werden, woN
is.width()
ist, wennis.width() > 0
, sonstN
iststr.max_size()
Original:N
characters are read, whereN
isis.width()
ifis.width() > 0
, otherwiseN
isstr.max_size()
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.- die End-of-File-Bedingung tritt im Strom
is
Original:the end-of-file condition occurs in the streamis
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions. - std::isspace(c,is.getloc()) ist für das nächste Zeichen
c
inis
(dies Leerzeichen bleibt in der Input-Stream) wahr .Original:std::isspace(c,is.getloc()) is true for the next characterc
inis
(this whitespace character remains in the input stream).The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Wenn keine Zeichen werden dann extrahiert std::ios::failbit auf
is
, die std::ios_base::failure werfen kann eingestellt .Original:
If no characters are extracted then std::ios::failbit is set on
is
, which may throw std::ios_base::failure.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.
Schließlich ruft os.width(0) und zerstört die std::basic_istream::sentry Objekt .
Original:
Finally, calls os.width(0) and destroys the std::basic_istream::sentry object.
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.
Inhaltsverzeichnis |
[Bearbeiten]Ausnahmen
1)kann std::ios_base::failure werfen, wenn eine Ausnahme während der Ausgabe geworfen wird .
2) Original:
may throw std::ios_base::failure if an exception is thrown during output.
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.
kann std::ios_base::failure werfen, wenn keine Zeichen aus
is
extrahiert werden (zB der Strom am Ende der Datei, oder aus Leerzeichen only), oder wenn eine Ausnahme während der Eingabe geworfen .Original:
may throw std::ios_base::failure if no characters are extracted from
is
(e.g the stream is at end of file, or consists of whitespace only), or if an exception is thrown during input.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.
[Bearbeiten]Parameter
os | - | ein Zeichen Ausgabestream Original: a character output stream The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. |
is | - | ein Charakter Eingabestrom Original: a character input stream The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. |
str | - | die Zeichenkette eingefügt oder entnommen werden Original: the string to be inserted or extracted 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
1) os
2) is
[Bearbeiten]Beispiel
#include <iostream>#include <string> int main(){std::string greeting ="Hello, whirled!"std::cout<< greeting <<'\n';}
Output:
Hello, whirled!