operator<< (<ostream>)
Escribe diferentes tipos a la secuencia.
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 _Ty>
basic_ostream<_Elem, _Tr>& operator<<(
basic_ostream<_Elem, _Tr>&& _Ostr,
Ty _Val
);
Parámetros
_Ch
Carácter._Elem
Tipo del elemento._Ostr
Un objeto basic_ostream._Str
una cadena de caracteres._Tr
rasgos de carácter._Val
el tipo
Valor devuelto
la secuencia.
Comentarios
La clase de basic_ostream también define varios operadores de inserción.Para obtener más información, vea basic_ostream::operator<<.
La función de plantilla
template<class _Elem, class _Tr>
basic_ostream<Elem, _Tr>& operator<<(
basic_ostream<Elem, _Tr>& _ostr,
const Elem *_Str);
determina la n = traits_type::longitud(_Str) del principio de la secuencia en _Str, y la secuencia.Si n < _Ostr.ancho, la función también inserta una repetición de _Ostr.width - caracteres de relleno de n._Ostr83dk98wz(v=vs.110).mdadjustfield¡Repetición precede a la secuencia si (_Ostr.flags83dk98wz(v=vs.110).md yadjustfield! =salido.Si no, repetición sigue la secuencia.la función devuelve _Ostr.
La función de plantilla
template<class _Elem, class _Tr>
basic_ostream<Elem, _Tr>& operator<<(
basic_ostream<Elem, _Tr>& _Ostr,
Elem _Ch);
inserta el elemento _Ch.Si 1 < _Ostr.width, la función también inserta una repetición de _Ostr.width - caracteres de 1 relleno.Repetición precede a la secuencia si _Ostr.flags & adjustfield != left.Si no, repetición sigue la secuencia.devuelve _Ostr.
La función de plantilla
template<class _Elem, class _Tr>
basic_ostream<Elem, _Tr>& operator<<(
basic_ostream<Elem, _Tr>& _Ostr,
const char *_Str);
se comporta igual que
template<class _Elem, class _Tr>
basic_ostream<Elem, _Tr>& operator<<(
basic_ostream<Elem, _Tr>& _Ostr,
const Elem *_Str);
excepto en que cada elemento _Ch inicial de la secuencia en _Str se convierte en un objeto de Elem tipo llamando a _Ostr.título(_Ostr.se amplía(_Ch)).
La función de plantilla
template<class _Elem, class _Tr>
basic_ostream<Elem, _Tr>& operator<<(
basic_ostream<Elem, _Tr>& _Ostr,
char _Ch);
se comporta igual que
template<class _Elem, class _Tr>
basic_ostream<Elem, _Tr>& operator<<(
basic_ostream<Elem, _Tr>& _Ostr,
Elem _Ch);
salvo que _Ch se convierte en un objeto de Elem tipo llamando a _Ostr.put(_Ostr.widen(_Ch)).
La función de plantilla
template<class _Tr>
basic_ostream<char, _Tr>& operator<<(
basic_ostream<char, _Tr>& _Ostr,
const char *_Str);
se comporta igual que
template<class _Elem, class _Tr>
basic_ostream<Elem, _Tr>& operator<<(
basic_ostream<Elem, _Tr>& _Ostr,
const Elem *_Str);
(No tiene que ampliar los elementos antes de insertarlos.)
La función de plantilla
template<class _Tr>
basic_ostream<char, Tr>& operator<<(
basic_ostream<char, _Tr>& _Ostr,
char _Ch);
se comporta igual que
template<class _Elem, class _Tr>
basic_ostream<Elem, _Tr>& operator<<(
basic_ostream<Elem, _Tr>& _Ostr,
Elem _Ch);
(No tiene que ampliar _Ch antes de insertarlo.)
La función de plantilla
template<class _Tr>
basic_ostream<char, _Tr>& operator<<(
basic_ostream<char, _Tr>& _Ostr,
const signed char *_Str);
devuelve _Ostr << (const char *)_Str.
La función de plantilla
template<class _Tr>
basic_ostream<char, _Tr>& operator<<(
basic_ostream<char, _Tr>& _Ostr,
signed char _Ch);
devuelve _Ostr << (char)_Ch.
La función de plantilla:
template<class _Tr>
basic_ostream<char, _Tr>& operator<<(
basic_ostream<char, _Tr>& _Ostr,
const unsigned char *_Str);
devuelve _Ostr << (const char *)_Str.
La función de plantilla:
template<class _Tr>
basic_ostream<char, _Tr>& operator<<(
basic_ostream<char, _Tr>& _Ostr,
unsigned char _Ch);
devuelve _Ostr << (char)_Ch.
La función de plantilla:
template<class _Elem, class _Tr, class _Ty>
basic_ostream<_Elem, _Tr>& operator<<(
basic_ostream<char, _Tr>&& _Ostr,
_Ty _Val
);
devuelve _Ostr<<_Val (y convierte referencia de RValue a _Ostr un valor l en el proceso).
Ejemplo
Vea vaciado para obtener un ejemplo sobre el uso operator<<.
Requisitos
encabezado: <ostream>
espacio de nombres: std