basic_ostream::operator<<
Zapisuje strumienia.
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
);
Parametry
_Pfn
Wskaźnik funkcji._Strbuf
Wskaźnik do stream_buf obiektu._Val
Element zapisu do strumienia.
Wartość zwracana
Odwołanie do obiektu basic_ostream.
Uwagi
<ostream> Nagłówka definiuje również kilka operatorów wstawiania globalnego.Aby uzyskać więcej informacji, zobacz operator<< (<ostream>).
Pierwsza funkcja Członkowskie zapewnia, że wyrażenie postaci ostr << endl wywołania endl(ostr), a następnie zwraca * to.Funkcje drugiego i trzeciego zapewnienia innych manipulatory, takich jak hex, zachowują się podobnie.Pozostałe funkcje są wszystkie funkcje sformatowane dane wyjściowe.
Funkcja
basic_ostream<_Elem, _Tr>& operator<<(basic_streambuf<Elem, Tr> *_Strbuf);
wyodrębnia elementy z _Strbuf, jeśli _Strbuf nie jest wskaźnik zerowy i wstawia je.Ekstrakcja zatrzymuje się na koniec pliku, lub jeśli Ekstrakcja zgłasza wyjątek, (która jest rethrown).Powoduje także zatrzymanie, bez wyodrębniania danego, jeśli nie wstawiania elementów.Jeśli funkcja nie wstawia żadnych elementów lub jeśli Ekstrakcja zgłasza wyjątek, wywołuje funkcję setstate(failbit).W każdym przypadku, funkcja zwraca * to.
Funkcja
basic_ostream<_Elem, _Tr>& operator<<(bool _Val);
Konwertuje _Val wartość logiczna pola i wstawia go przez wywołanie use_facet< num_put < Elem, OutIt >(getloc).put(OutIt(rdbuf), *this, getloc, val).W tym miejscu OutIt jest zdefiniowana jako ostreambuf_iterator< Elem, Tr >.Funkcja zwraca * to.
Funkcje
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);
Konwertowanie każdego _Val do numeryczna pola i wstaw go przez wywołanie use_facet < num_put < Elem, OutIt >(getloc). put(OutIt(rdbuf), *this, getloc, val).W tym miejscu OutIt jest zdefiniowana jako ostreambuf_iterator < Elem, Tr >.Funkcja zwraca * to.
Funkcje
basic_ostream<_Elem, _Tr>& operator<<(float _Val);
basic_ostream<_Elem, _Tr>& operator<<(double _Val);
basic_ostream<_Elem, _Tr>& operator<<(long double _Val);
Konwertowanie każdego _Val do numeryczna pola i wstaw go przez wywołanie use_facet < num_put < Elem, OutIt >(getloc). put(OutIt(rdbuf), *this, getloc, val).W tym miejscu OutIt jest zdefiniowana jako ostreambuf_iterator < Elem, Tr >.Funkcja zwraca * to.
Przykład
// 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;
}
Dane wyjściowe
i is cout
21
15
text in streambuf
Wymagania
Nagłówek: <ostream>
Obszar nazw: std