basic_ostream::operator<<
Scrive nel flusso.
basic_ostream<_Elem, _Tr>& operator<<(
basic_ostream<_Elem, _Tr>& (*_Pfn)(basic_ostream<_Elem, _Tr>&)
);
basic_ostream<_Elem, _Tr>& operator<<(
ios_base& (*_Pfn)(ios_base&)
);
basic_ostream<_Elem, _Tr>& operator<<(
basic_ios<_Elem, _Tr>& (*_Pfn)(basic_ios<_Elem, _Tr>&)
);
basic_ostream<_Elem, _Tr>& operator<<(
basic_streambuf<_Elem, _Tr> *_Strbuf
);
basic_ostream<_Elem, _Tr>& operator<<(
bool _Val
);
basic_ostream<_Elem, _Tr>& operator<<(
short _Val
);
basic_ostream<_Elem, _Tr>& operator<<(
unsigned short _Val
);
basic_ostream<_Elem, _Tr>& operator<<(
int __w64 _Val
);
basic_ostream<_Elem, _Tr>& operator<<(
unsigned int __w64 _Val
);
basic_ostream<_Elem, _Tr>& operator<<(
long _Val
);
basic_ostream<_Elem, _Tr>& operator<<(
unsigned long __w64 _Val
);
basic_ostream<_Elem, _Tr>& operator<<(
long long _Val
);
basic_ostream<_Elem, _Tr>& operator<<(
unsigned long long _Val
);
basic_ostream<_Elem, _Tr>& operator<<(
float _Val
);
basic_ostream<_Elem, _Tr>& operator<<(
double _Val
);
basic_ostream<_Elem, _Tr>& operator<<(
long double _Val
);
basic_ostream<_Elem, _Tr>& operator<<(
const void *_Val
);
Parametri
_Pfn
Puntatore a funzione._Strbuf
Un puntatore a un oggetto stream_buf._Val
Un elemento nel flusso.
Valore restituito
Un riferimento all'oggetto del basic_ostream.
Note
L'intestazione <ostream> definisce inoltre numerosi operatori globali di inserimento.Per ulteriori informazioni, vedere operator<< (<ostream>).
La prima funzione membro assicura che un'espressione del form ostr << endl chiamare endl**(ostr)**quindi restituisce *this.Nella seconda e la terza funzioni garantiscono che altri manipolatori, come esadecimali, si comportino nello stesso modo.Le funzioni rimanenti sono tutte le funzioni di output formattato.
La funzione
basic_ostream<_Elem, _Tr>& operator<<(basic_streambuf<Elem, Tr> *_Strbuf);
estrae gli elementi da _Strbuf, se _Strbuf non è un puntatore null e li inserisce.Le estrazioni si arresta alla fine di file, o se un'estrazione genera un'eccezione (che viene generata).Si interrompe, senza estrarre l'elemento in questione, se un inserimento non riesce.Se la funzione non inserire elementi, o se un'estrazione genera un'eccezione, le chiamate di funzione setstate(failbit).Tuttavia, la funzione restituisce *this.
La funzione
basic_ostream<_Elem, _Tr>& operator<<(bool _Val);
converte _Val a un campo booleano e lo inserisce chiamando use_facet<num_put<Elem, OutIt>(getloc).inserito(OutIt(rdbuf), *this, getloc, val).In questo caso, OutIt viene definito come ostreambuf_iterator<Elem, Tr>.La funzione restituisce *this.
Le funzioni
basic_ostream<_Elem, _Tr>& operator<<(short _Val);
basic_ostream<_Elem, _Tr>& operator<<(unsigned short _Val);
basic_ostream<_Elem, _Tr>& operator<<(int _Val);
basic_ostream<_Elem, _Tr>& operator<<(unsigned int __w64 _Val);
basic_ostream<_Elem, _Tr>& operator<<(long _Val);
basic_ostream<_Elem, _Tr>& operator<<(unsigned long _Val);
basic_ostream<_Elem, _Tr>& operator<<(long long _Val);
basic_ostream<_Elem, _Tr>& operator<<(unsigned long long _Val);
basic_ostream<_Elem, _Tr>& operator<<(const void *_Val);
ogni convertito _Val a un campo numerico e lo inserisce chiamando use_facet<num_put<Elem, OutIt>(getloc). put(OutIt(rdbuf), *this, getloc, val).In questo caso, OutIt viene definito come ostreambuf_iterator<Elem, Tr>.La funzione restituisce *this.
Le funzioni
basic_ostream<_Elem, _Tr>& operator<<(float _Val);
basic_ostream<_Elem, _Tr>& operator<<(double _Val);
basic_ostream<_Elem, _Tr>& operator<<(long double _Val);
ogni _Val in un campo numerico e lo inserisce chiamando use_facet<num_put<Elem, OutIt>(getloc). put(OutIt(rdbuf), *this, getloc, val).In questo caso, OutIt viene definito come ostreambuf_iterator<Elem, Tr>.La funzione restituisce *this.
Esempio
// basic_ostream_op_write.cpp
// compile with: /EHsc
#include <iostream>
#include <string.h>
using namespace std;
ios_base& hex2( ios_base& ib )
{
ib.unsetf( ios_base::dec );
ib.setf( ios_base::hex );
return ib;
}
basic_ostream<char, char_traits<char> >& somefunc(basic_ostream<char, char_traits<char> > &i)
{
if ( i == cout )
{
i << "i is cout" << endl;
}
return i;
}
class CTxtStreambuf : public basic_streambuf< char, char_traits< char > >
{
public:
CTxtStreambuf(char *_pszText)
{
pszText = _pszText;
setg(pszText, pszText, pszText+strlen(pszText));
};
char *pszText;
};
int main( )
{
cout << somefunc;
cout << 21 << endl;
hex2(cout);
cout << 21 << endl;
CTxtStreambuf f("text in streambuf");
cout << &f << endl;
}
Output
i is cout
21
15
text in streambuf
Requisiti
intestazione: <ostream>
Spazio dei nomi: deviazione standard