Nota
L'accesso a questa pagina richiede l'autorizzazione. È possibile provare ad accedere o modificare le directory.
L'accesso a questa pagina richiede l'autorizzazione. È possibile provare a modificare le directory.
Operatori
L'intestazione <ostream> fornisce gli operatori seguenti:
operator<<
Scrive vari tipi nel flusso.
template <class _Elem, class _Tr>
basic_ostream<_Elem, _Tr>& operator<<(
basic_ostream<_Elem, _Tr>& _Ostr,
const Elem* str);
template <class _Elem, class _Tr>
basic_ostream<_Elem, _Tr>& operator<<(
basic_ostream<_Elem, _Tr>& _Ostr,
Elem _Ch);
template <class _Elem, class _Tr>
basic_ostream<_Elem, _Tr>& operator<<(
basic_ostream<_Elem, _Tr>& _Ostr,
const char* str);
template <class _Elem, class _Tr>
basic_ostream<_Elem, _Tr>& operator<<(
basic_ostream<_Elem, _Tr>& _Ostr,
char _Ch);
template <class _Tr>
basic_ostream<char, _Tr>& operator<<(
basic_ostream<char, _Tr>& _Ostr,
const char* str);
template <class _Tr>
basic_ostream<char, _Tr>& operator<<(
basic_ostream<char, _Tr>& _ostr,
char _Ch);
template <class _Tr>
basic_ostream<char, _Tr>& operator<<(
basic_ostream<char, _Tr>& _Ostr,
const signed char* str);
template <class _Tr>
basic_ostream<char, _Tr>& operator<<(
basic_ostream<char, _Tr>& _Ostr,
signed char _Ch);
template <class _Tr>
basic_ostream<char, _Tr>& operator<<(
basic_ostream<char, _Tr>& _Ostr,
const unsigned char* str);
template <class _Tr>
basic_ostream<char, _Tr>& operator<<(
basic_ostream<char, _Tr>& _Ostr,
unsigned char _Ch);
template <class _Elem, class _Tr, class T>
basic_ostream <_Elem, _Tr>& operator<<(
basic_ostream<_Elem, _Tr>&& _Ostr,
Ty val);
Parametri
_Ch
Carattere.
_Elem
Tipo dell'elemento.
_Ostr
Oggetto basic_ostream.
Str
Stringa di caratteri.
_Tr
Tratti di carattere.
Val
Il tipo
Valore restituito
Flusso.
Osservazioni:
La classe basic_ostream definisce inoltre diversi operatori di inserimento. Per ulteriori informazioni, vedere basic_ostream::operator<<.
La funzione modello
template <class _Elem, class _Tr>
basic_ostream<Elem, _Tr>& operator<<(
basic_ostream<Elem, _Tr>& _ostr,
const Elem *str);
determina la lunghezza N = traits_type::length(str) della sequenza a partire da str e inserisce la sequenza. Se N <_Ostr.width, la funzione inserisce anche una ripetizione di _Ostr.width - N caratteri di riempimento. La ripetizione precede la sequenza se (_Ostr.
flags & adjustfield != left. In caso contrario, la ripetizione segue la sequenza. La funzione restituisce _Ostr.
La funzione modello
template <class _Elem, class _Tr>
basic_ostream<Elem, _Tr>& operator<<(
basic_ostream<Elem, _Tr>& _Ostr,
Elem _Ch);
inserisce l'elemento _Ch. Se 1 <_Ostr.width, la funzione inserisce anche una ripetizione di _Ostr.width - 1 caratteri di riempimento. La ripetizione precede la sequenza se _Ostr.flags & adjustfield != left. In caso contrario, la ripetizione segue la sequenza. Restituisce _Ostr.
La funzione modello
template <class _Elem, class _Tr>
basic_ostream<Elem, _Tr>& operator<<(
basic_ostream<Elem, _Tr>& _Ostr,
const char *str);
si comporta allo stesso modo di
template <class _Elem, class _Tr>
basic_ostream<Elem, _Tr>& operator<<(
basic_ostream<Elem, _Tr>& _Ostr,
const Elem *str);
ad eccezione del fatto che ogni elemento _Ch della sequenza che inizia da str viene convertito in un oggetto di tipo Elem chiamando _Ostr.put(_Ostr.widen(_Ch)).
La funzione modello
template <class _Elem, class _Tr>
basic_ostream<Elem, _Tr>& operator<<(
basic_ostream<Elem, _Tr>& _Ostr,
char _Ch);
si comporta allo stesso modo di
template <class _Elem, class _Tr>
basic_ostream<Elem, _Tr>& operator<<(
basic_ostream<Elem, _Tr>& _Ostr,
Elem _Ch);
ad eccezione del fatto che _Ch viene convertito in un oggetto di tipo Elem chiamando _Ostr.put( _Ostr.widen( _Ch )).
La funzione modello
template <class _Tr>
basic_ostream<char, _Tr>& operator<<(
basic_ostream<char, _Tr>& _Ostr,
const char *str);
si comporta allo stesso modo di
template <class _Elem, class _Tr>
basic_ostream<Elem, _Tr>& operator<<(
basic_ostream<Elem, _Tr>& _Ostr,
const Elem *str);
Non è necessario espandere gli elementi prima di inserirli.
La funzione modello
template <class _Tr>
basic_ostream<char, Tr>& operator<<(
basic_ostream<char, _Tr>& _Ostr,
char _Ch);
si comporta allo stesso modo di
template <class _Elem, class _Tr>
basic_ostream<Elem, _Tr>& operator<<(
basic_ostream<Elem, _Tr>& _Ostr,
Elem _Ch);
Non è necessario ampliare _Ch prima di inserirlo.
La funzione modello
template <class _Tr>
basic_ostream<char, _Tr>& operator<<(
basic_ostream<char, _Tr>& _Ostr,
const signed char *str);
Restituisce _Ostr << (const char *)str.
La funzione modello
template <class _Tr>
basic_ostream<char, _Tr>& operator<<(
basic_ostream<char, _Tr>& _Ostr,
signed char _Ch);
Restituisce _Ostr << (char)_Ch.
La funzione modello:
template <class _Tr>
basic_ostream<char, _Tr>& operator<<(
basic_ostream<char, _Tr>& _Ostr,
const unsigned char *str);
Restituisce _Ostr << (const char *)str.
La funzione modello:
template <class _Tr>
basic_ostream<char, _Tr>& operator<<(
basic_ostream<char, _Tr>& _Ostr,
unsigned char _Ch);
Restituisce _Ostr << (char)_Ch.
La funzione modello:
template <class _Elem, class _Tr, class T>
basic_ostream<_Elem, _Tr>& operator<<(
basic_ostream<char, _Tr>&& _Ostr,
T val);
restituisce _Ostr << val e converte un riferimento RValue in _Ostr in un oggetto lvalue nel processo.
Esempio
Vedere flush per indicazioni su come usare operator<<.