<ostream>
– operátory
operator<<
Zapisuje do datového proudu různé typy.
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);
Parametry
_Ch
Znak.
_Elem
Typ elementu.
_Ostr
Objekt basic_ostream
.
Str
Řetězec znaků.
_Tr
Charakterové vlastnosti.
Val
Typ
Návratová hodnota
Stream.
Poznámky
Třída basic_ostream
také definuje několik operátorů vložení. Další informace najdete na webu basic_ostream::operator<<
.
Funkce šablony
template <class _Elem, class _Tr>
basic_ostream<Elem, _Tr>& operator<<(
basic_ostream<Elem, _Tr>& _ostr,
const Elem *str);
určuje délku N = traits_type::
length(str
) sekvence začínající na str a vloží sekvenci. Pokud je šířka N<_Ostr.
, vloží funkce také opakování _Ostr.width
znaků - N výplně. Opakování předchází sekvenci if (_Ostr
. příznaky & adjustfield
!= vlevo. V opačném případě se opakování řídí sekvencí. Funkce vrátí _Ostr.
Funkce šablony
template <class _Elem, class _Tr>
basic_ostream<Elem, _Tr>& operator<<(
basic_ostream<Elem, _Tr>& _Ostr,
Elem _Ch);
vloží prvek _Ch
. Pokud 1 <_Ostr.width
, funkce vloží také opakování _Ostr.width
- 1 znaky výplně. Opakování předchází sekvenci, pokud _Ostr.flags & adjustfield != left
. V opačném případě se opakování řídí sekvencí. Vrátí _Ostr.
Funkce šablony
template <class _Elem, class _Tr>
basic_ostream<Elem, _Tr>& operator<<(
basic_ostream<Elem, _Tr>& _Ostr,
const char *str);
chová se stejně jako
template <class _Elem, class _Tr>
basic_ostream<Elem, _Tr>& operator<<(
basic_ostream<Elem, _Tr>& _Ostr,
const Elem *str);
kromě toho, že každý prvek _Ch sekvence začínající na str je převeden na objekt typu Elem
volání _Ostr.
put(_Ostr.
rozšiřující(_Ch
)).
Funkce šablony
template <class _Elem, class _Tr>
basic_ostream<Elem, _Tr>& operator<<(
basic_ostream<Elem, _Tr>& _Ostr,
char _Ch);
chová se stejně jako
template <class _Elem, class _Tr>
basic_ostream<Elem, _Tr>& operator<<(
basic_ostream<Elem, _Tr>& _Ostr,
Elem _Ch);
kromě toho, že _Ch je převeden na objekt typu Elem
voláním _Ostr.put( _Ostr.widen( _Ch ))
.
Funkce šablony
template <class _Tr>
basic_ostream<char, _Tr>& operator<<(
basic_ostream<char, _Tr>& _Ostr,
const char *str);
chová se stejně jako
template <class _Elem, class _Tr>
basic_ostream<Elem, _Tr>& operator<<(
basic_ostream<Elem, _Tr>& _Ostr,
const Elem *str);
(Před vložením prvků není nutné prvky rozšířit.)
Funkce šablony
template <class _Tr>
basic_ostream<char, Tr>& operator<<(
basic_ostream<char, _Tr>& _Ostr,
char _Ch);
chová se stejně jako
template <class _Elem, class _Tr>
basic_ostream<Elem, _Tr>& operator<<(
basic_ostream<Elem, _Tr>& _Ostr,
Elem _Ch);
(Před vložením není nutné rozšířit _Ch .)
Funkce šablony
template <class _Tr>
basic_ostream<char, _Tr>& operator<<(
basic_ostream<char, _Tr>& _Ostr,
const signed char *str);
vrátí _Ostr << (const char *)str
.
Funkce šablony
template <class _Tr>
basic_ostream<char, _Tr>& operator<<(
basic_ostream<char, _Tr>& _Ostr,
signed char _Ch);
vrátí _Ostr << (char)_Ch
.
Funkce šablony:
template <class _Tr>
basic_ostream<char, _Tr>& operator<<(
basic_ostream<char, _Tr>& _Ostr,
const unsigned char *str);
vrátí _Ostr << (const char *)str
.
Funkce šablony:
template <class _Tr>
basic_ostream<char, _Tr>& operator<<(
basic_ostream<char, _Tr>& _Ostr,
unsigned char _Ch);
vrátí _Ostr << (char)_Ch
.
Funkce šablony:
template <class _Elem, class _Tr, class T>
basic_ostream<_Elem, _Tr>& operator<<(
basic_ostream<char, _Tr>&& _Ostr,
T val);
vrátí _Ostr << val
(a převede odkaz RValue na _Ostr
lvalue v procesu).
Příklad
Viz vyprázdnění příkladu pomocí operator<<
.