std::basic_ostream::operator<<
Da cppreference.com.
< cpp | io | basic ostream
![]() |
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. |
basic_ostream& operator<<( short value ); basic_ostream& operator<<( unsigned short value ); |
(1) | |
basic_ostream& operator<<( int value ); basic_ostream& operator<<( unsigned int value ); |
(2) | |
basic_ostream& operator<<( long value ); basic_ostream& operator<<( unsigned long value ); |
(3) | |
basic_ostream& operator<<( long long value ); basic_ostream& operator<<( unsigned long long value ); |
(4) | (dal C++11) |
basic_ostream& operator<<( float value ); basic_ostream& operator<<( double value ); |
(5) | |
basic_ostream& operator<<( bool value ); |
(6) | |
basic_ostream& operator<<( const void* value ); |
(7) | |
basic_ostream& operator<<( std::basic_streambuf<CharT, Traits>* sb); |
(8) | |
basic_ostream& operator<<( basic_ostream& st, std::ios_base& (*func)(std::ios_base&) ); |
(9) | |
Inserisce i dati nel flusso.
Original:
Inserts data into the stream.
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.
Le (1-7) versioni del gestore si comportano come funzioni di output formattato, e la 8) versione si comporta funzione di output non formattato. Queste funzioni avviare l'esecuzione con la costruzione di un oggetto di tipo
1-2) sentry
, che svuota il buffer di uscita tie()'d, se necessario, e controlla gli errori del flusso. Dopo la costruzione, se i rendimenti sentinella oggetto false, le funzioni restituiscono senza tentare alcun output. Se si verifica un errore durante l'uscita, le funzioni di uscita in formato impostato setstate(ios_base::failbit). Se viene generata un'eccezione durante l'uscita, poi ios :: badbit è impostato (l'eccezione è soppressa a meno (exceptions()&badbit) != 0, nel qual caso viene rilanciata)Original:
The (1-7) versions of the operator behave as formatted output functions, and the 8) version behaves as unformatted output function. These functions begin execution by constructing an object of type
sentry
, which flushes the tie()'d output buffers if necessary and checks the stream errors. After construction, if the sentry object returns false, the functions return without attempting any output. If an error occurs during output, formatted output functions set setstate(ios_base::failbit). If an exception is thrown during output, then ios::badbit is set (the exception is suppressed unless (exceptions()&badbit) != 0, in which case it is rethrown)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
3-4) value
è short o int, poi getta a unsigned short o unsigned int se ios_base::flags() & ios_base::basefield è ios_base::oct o ios_base::hex. Dopo di che, getta a long in ogni caso e uscite come in 3). Se value
è unsigned short o unsigned int, getta a unsigned long e uscite come in 3)Original:
If
value
is short or int, then casts it to unsigned short or unsigned int if ios_base::flags() & ios_base::basefield is ios_base::oct or ios_base::hex. After that, casts to long in any case and outputs as in 3). If value
is unsigned short or unsigned int, casts to unsigned long and outputs as in 3)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.
Inserisce un valore intero chiamando num_put::put(). Se la condizione di fine file è stato rilevato durante l'uscita (put().failed() == true), stabilisce ios::badbit.
5) Original:
Inserts an integer value by calling num_put::put(). If the end of file condition was encountered during output (put().failed() == true), sets ios::badbit.
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.
Inserisce un valore in virgola mobile chiamando num_put::put() Se la condizione di fine file è stato rilevato durante l'uscita (put().failed() == true), imposta ios::badbit.
6) Original:
Inserts a floating point value by calling num_put::put() If the end of file condition was encountered during output (put().failed() == true), sets ios::badbit.
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.
Inserti bool valore chiamando num_put::put() Se la condizione di fine file è stato rilevato durante l'uscita (put().failed() == true), imposta ios::badbit.
7) Original:
Inserts bool value by calling num_put::put() If the end of file condition was encountered during output (put().failed() == true), sets ios::badbit.
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.
Inserisce un valore puntatore generico chiamando num_put::put() Se la condizione di fine file è stato rilevato durante l'uscita (put().failed() == true), imposta ios::badbit.
8) Original:
Inserts a generic pointer value by calling num_put::put() If the end of file condition was encountered during output (put().failed() == true), sets ios::badbit.
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.
Inserisce tutti i dati dal
sb
. Dopo la creazione dell'oggetto di sentinella, controlla se sb
è un puntatore nullo. Se lo è, esegue setstate(badbit) ed esce. In caso contrario, estrae i caratteri dalla sequenza di input controllato da sb
e le inserisce in *this fino a quando una delle seguenti condizioni sono soddisfatte:Original:
Inserts all data from
sb
. After constructing the sentry object, checks if sb
is a null pointer. If it is, executes setstate(badbit) and exits. Otherwise, extracts characters from the input sequence controlled by sb
and inserts them into *this until 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.
- end-of-file avviene sulla sequenza di input;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. - inserire nella sequenza di uscita fallisce (nel qual caso il carattere da inserire non viene estratto)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. - si verifica un'eccezione (in questo caso l'eccezione e 'colto).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.
-
Se non sono stati inseriti caratteri, esegue setstate(badbit). Se viene generata un'eccezione durante l'estrazione, imposta failbit
9) Original:
If no characters were inserted, executes setstate(badbit). If an exception was thrown while extracting, sets failbit
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.
Chiamate func(*this);. Questo sovraccarico è utilizzato per implementare uscita I / O manipolatori come std::endl.
Original:
Calls func(*this);. This overload is used to implement output I/O manipulators such as std::endl.
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
value | - | intero, a virgola mobile, valore booleano, o puntatore da inserire
Original: integer, floating-point, boolean, or pointer value to insert The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. |
func | - | funzione da chiamare
Original: function to call The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. |
sb | - | puntatore alla streambuffer a leggere i dati
Original: pointer to the streambuffer to read the data from The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. |
[modifica] Valore di ritorno
*this
[modifica] Note
Non ci sono il sovraccarico per i puntatori a puntatori volatili o di una funzione (diversi da quelli con le firme accettate 9) sovraccarico). Il tentativo di produrre tali oggetti invoca conversione implicita a bool, e, per ogni valore non nullo del puntatore, il 1 valore viene stampato (a meno che non boolalpha è stato impostato).
Original:
There are no overload for pointers to volatile or function pointers (other than the ones with signatures accepted by the 9) overload). Attempting to output such objects invokes implicit conversion to bool, and, for any non-null pointer value, the value 1 is printed (unless boolalpha was set).
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 <iomanip> #include <sstream> int main() { std::istringstream input(" \"Some text.\" "); volatile int n = 42; double f = 3.14; bool b = true;; std::cout << n // int overload << ' ' // non-member overload << std::boolalpha << b // bool overload << " " // non-member overload << std::fixed << f // double overload << input.rdbuf() // streambuf overload << &n // bool overload << std::endl; // function overload }
Output:
42 true 3.140000 "Some text." true
[modifica] Vedi anche
inserisce i dati carattere Original: inserts character data The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (funzione) | |
esegue lo streaming di I / O di stringhe 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. (funzione di modello) | |
esegue flusso di input e output di bitset 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. (funzione) | |
serializza e deserializza un numero complesso 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. (funzione di modello) | |
esegue flusso di ingresso e di uscita sul pseudo-casuale numero di motore Original: performs stream input and output on pseudo-random number engine The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (funzione) | |
esegue flusso di ingresso e di uscita sul pseudo-casuale distribuzione numerica Original: performs stream input and output on pseudo-random number distribution The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (funzione) | |
inserisce un carattere Original: inserts a character The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (metodo pubblico) | |
blocchi inserti di caratteri Original: inserts 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. (metodo pubblico) |