<ostream> Operatoren

operator<<

operator<<

Schreibt verschiedene Typen in den 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);

Parameter

_Ch
Ein Zeichen.

_Elem
Der Elementtyp.

_Ostr
Ein basic_ostream-Objekt.

str
Eine Zeichenfolge.

_Tr
Zeichenmerkmale.

val
Der Typ

Rückgabewert

Der Datenstrom.

Hinweise

Die basic_ostream-Klasse definiert außerdem mehrere Einfügeoperatoren. Weitere Informationen finden Sie unter basic_ostream::operator<<.

Die Vorlagenfunktion

template <class _Elem, class _Tr>
basic_ostream<Elem, _Tr>& operator<<(
    basic_ostream<Elem, _Tr>& _ostr,
    const Elem *str);

bestimmt die Länge N = traits_type::length(str) der Sequenz, die bei str beginnt, und fügt die Sequenz ein. Wenn N-Breite<_Ostr., fügt die Funktion auch eine Wiederholung von _Ostr.width - N-Füllzeichen ein. Die Wiederholung steht vor der Sequenz, wenn (_Ostr. Flags & adjustfield != links. Andernfalls folgt die Wiederholung der Sequenz. Die Funktion gibt _Ostr zurück.

Die Vorlagenfunktion

template <class _Elem, class _Tr>
basic_ostream<Elem, _Tr>& operator<<(
    basic_ostream<Elem, _Tr>& _Ostr,
    Elem _Ch);

fügt das Element _Ch ein. Wenn 1 <_Ostr.width, fügt die Funktion auch eine Wiederholung von _Ostr.width - 1 Füllzeichen ein. Die Wiederholung geht der Sequenz voraus, wenn ( _Ostr.flags & adjustfield != left. Andernfalls folgt die Wiederholung der Sequenz. Sie gibt _Ostr zurück.

Die Vorlagenfunktion

template <class _Elem, class _Tr>
basic_ostream<Elem, _Tr>& operator<<(
    basic_ostream<Elem, _Tr>& _Ostr,
    const char *str);

verhält sich so

template <class _Elem, class _Tr>
basic_ostream<Elem, _Tr>& operator<<(
    basic_ostream<Elem, _Tr>& _Ostr,
    const Elem *str);

außer dass jedes Element _Ch der Sequenz, die bei str beginnt, in ein Objekt vom Typ Elem konvertiert wird, indem put(_Ostr.widen(_Ch)) aufgerufen _Ostr.wird.

Die Vorlagenfunktion

template <class _Elem, class _Tr>
basic_ostream<Elem, _Tr>& operator<<(
    basic_ostream<Elem, _Tr>& _Ostr,
    char _Ch);

verhält sich so

template <class _Elem, class _Tr>
basic_ostream<Elem, _Tr>& operator<<(
    basic_ostream<Elem, _Tr>& _Ostr,
    Elem _Ch);

außer dass _Ch durch Aufrufen von Aufrufen _Ostr.put( _Ostr.widen( _Ch ))in ein Objekt vom Typ Elem konvertiert wird.

Die Vorlagenfunktion

template <class _Tr>
basic_ostream<char, _Tr>& operator<<(
    basic_ostream<char, _Tr>& _Ostr,
    const char *str);

verhält sich so

template <class _Elem, class _Tr>
basic_ostream<Elem, _Tr>& operator<<(
    basic_ostream<Elem, _Tr>& _Ostr,
    const Elem *str);

(Sie muss die Elemente nicht erweitern, bevor sie eingefügt werden.)

Die Vorlagenfunktion

template <class _Tr>
basic_ostream<char, Tr>& operator<<(
    basic_ostream<char, _Tr>& _Ostr,
    char _Ch);

verhält sich so

template <class _Elem, class _Tr>
basic_ostream<Elem, _Tr>& operator<<(
    basic_ostream<Elem, _Tr>& _Ostr,
    Elem _Ch);

(Es muss vor dem Einfügen nicht _Ch erweitert werden.)

Die Vorlagenfunktion

template <class _Tr>
basic_ostream<char, _Tr>& operator<<(
    basic_ostream<char, _Tr>& _Ostr,
    const signed char *str);

_Ostr << (const char *)str wird zurückgegeben.

Die Vorlagenfunktion

template <class _Tr>
basic_ostream<char, _Tr>& operator<<(
    basic_ostream<char, _Tr>& _Ostr,
    signed char _Ch);

_Ostr << (char)_Ch wird zurückgegeben.

Die Vorlagenfunktion:

template <class _Tr>
basic_ostream<char, _Tr>& operator<<(
    basic_ostream<char, _Tr>& _Ostr,
    const unsigned char *str);

_Ostr << (const char *)str wird zurückgegeben.

Die Vorlagenfunktion:

template <class _Tr>
basic_ostream<char, _Tr>& operator<<(
    basic_ostream<char, _Tr>& _Ostr,
    unsigned char _Ch);

_Ostr << (char)_Ch wird zurückgegeben.

Die Vorlagenfunktion:

template <class _Elem, class _Tr, class T>
basic_ostream<_Elem, _Tr>& operator<<(
    basic_ostream<char, _Tr>&& _Ostr,
    T val);

gibt _Ostr << val zurück (und konvertiert einen RValue-Verweis zu _Ostr zu einem lvalue im Prozess).

Beispiel

Ein Beispiel für die Verwendung von operator<< finden Sie unter flush.

Siehe auch

<ostream>