Operadores <ostream><ostream> operators
Operator<<operator<<
Escribe varios tipos en la secuencia.Writes various types to the stream.
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);
ParámetrosParameters
_Ch_Ch
Un carácter.A character.
_Elem_Elem
El tipo de elemento.The element type.
_Ostr_Ostr
Un objeto basic_ostream
.A basic_ostream
object.
CADstr
Una cadena de caracteres.A character string.
_Tr_Tr
Rasgos de los caracteres.Character traits.
Valval
El tipoThe type
Valor devueltoReturn Value
Flujo.The stream.
ObservacionesRemarks
La clase basic_ostream
también define varios operadores de inserción.The basic_ostream
class also defines several insertion operators. Para obtener más información, vea basic_ostream:: < < Operator.For more information, see basic_ostream::operator<<.
La función de plantillaThe template function
template <class _Elem, class _Tr>
basic_ostream<Elem, _Tr>& operator<<(
basic_ostream<Elem, _Tr>& _ostr,
const Elem *str);
determina la longitud N = traits_type::
length( str
) de la secuencia que comienza en Str e inserta la secuencia.determines the length N = traits_type::
length(str
) of the sequence beginning at str, and inserts the sequence. Si N < _Ostr.
width, entonces la función también inserta una repetición de _Ostr.width
- N caracteres de relleno.If N < _Ostr.
width, then the function also inserts a repetition of _Ostr.width
- N fill characters. La repetición precede la secuencia si ( _Ostr
.The repetition precedes the sequence if (_Ostr
. marcas de & adjustfield
! = izquierda.flags & adjustfield
!= left. De otro modo, la repetición sigue la secuencia.Otherwise, the repetition follows the sequence. La función devuelve _Ostr.The function returns _Ostr.
La función de plantillaThe template function
template <class _Elem, class _Tr>
basic_ostream<Elem, _Tr>& operator<<(
basic_ostream<Elem, _Tr>& _Ostr,
Elem _Ch);
inserta el elemento _Ch
.inserts the element _Ch
. Si 1 < _Ostr.width
, entonces la función también inserta una repetición de _Ostr.width
- 1 caracteres de relleno.If 1 < _Ostr.width
, then the function also inserts a repetition of _Ostr.width
- 1 fill characters. La repetición precede la secuencia si _Ostr.flags & adjustfield != left
.The repetition precedes the sequence if _Ostr.flags & adjustfield != left
. De otro modo, la repetición sigue la secuencia.Otherwise, the repetition follows the sequence. Devuelve _Ostr.It returns _Ostr.
La función de plantillaThe template function
template <class _Elem, class _Tr>
basic_ostream<Elem, _Tr>& operator<<(
basic_ostream<Elem, _Tr>& _Ostr,
const char *str);
se comporta igual quebehaves the same as
template <class _Elem, class _Tr>
basic_ostream<Elem, _Tr>& operator<<(
basic_ostream<Elem, _Tr>& _Ostr,
const Elem *str);
salvo que cada elemento _Ch de la secuencia que comienza en Str se convierte en un objeto de tipo Elem
mediante una llamada a _Ostr.
Put( _Ostr.
Wide( _Ch
)).except that each element _Ch of the sequence beginning at str is converted to an object of type Elem
by calling _Ostr.
put(_Ostr.
widen(_Ch
)).
La función de plantillaThe template function
template <class _Elem, class _Tr>
basic_ostream<Elem, _Tr>& operator<<(
basic_ostream<Elem, _Tr>& _Ostr,
char _Ch);
se comporta igual quebehaves the same as
template <class _Elem, class _Tr>
basic_ostream<Elem, _Tr>& operator<<(
basic_ostream<Elem, _Tr>& _Ostr,
Elem _Ch);
con la excepción de que _Ch se convierte en un objeto de tipo Elem
mediante una llamada a _Ostr.put( _Ostr.widen( _Ch ))
.except that _Ch is converted to an object of type Elem
by calling _Ostr.put( _Ostr.widen( _Ch ))
.
La función de plantillaThe template function
template <class _Tr>
basic_ostream<char, _Tr>& operator<<(
basic_ostream<char, _Tr>& _Ostr,
const char *str);
se comporta igual quebehaves the same as
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).(It does not have to widen the elements before inserting them.)
La función de plantillaThe template function
template <class _Tr>
basic_ostream<char, Tr>& operator<<(
basic_ostream<char, _Tr>& _Ostr,
char _Ch);
se comporta igual quebehaves the same as
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).(It does not have to widen _Ch before inserting it.)
La función de plantillaThe template function
template <class _Tr>
basic_ostream<char, _Tr>& operator<<(
basic_ostream<char, _Tr>& _Ostr,
const signed char *str);
Devuelve _Ostr << (const char *)str
.returns _Ostr << (const char *)str
.
La función de plantillaThe template function
template <class _Tr>
basic_ostream<char, _Tr>& operator<<(
basic_ostream<char, _Tr>& _Ostr,
signed char _Ch);
Devuelve _Ostr << (char)_Ch
.returns _Ostr << (char)_Ch
.
La función de plantilla:The template function:
template <class _Tr>
basic_ostream<char, _Tr>& operator<<(
basic_ostream<char, _Tr>& _Ostr,
const unsigned char *str);
Devuelve _Ostr << (const char *)str
.returns _Ostr << (const char *)str
.
La función de plantilla:The template function:
template <class _Tr>
basic_ostream<char, _Tr>& operator<<(
basic_ostream<char, _Tr>& _Ostr,
unsigned char _Ch);
Devuelve _Ostr << (char)_Ch
.returns _Ostr << (char)_Ch
.
La función de plantilla:The template function:
template <class _Elem, class _Tr, class T>
basic_ostream<_Elem, _Tr>& operator<<(
basic_ostream<char, _Tr>&& _Ostr,
T val);
devuelve _Ostr << val
(y convierte una referencia a un valor R para _Ostr
en un valor L en el proceso).returns _Ostr << val
(and converts a RValue Reference to _Ostr
to an lvalue in the process).
EjemploExample
Vea flush para obtener un ejemplo que usa operator<<
.See flush for an example using operator<<
.