Kommentar
Åtkomst till den här sidan kräver auktorisering. Du kan prova att logga in eller ändra kataloger.
Åtkomst till den här sidan kräver auktorisering. Du kan prova att ändra kataloger.
Rubriken <ostream> innehåller följande operatorer:
operator<<
Skriver olika typer till strömmen.
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);
Parameterar
_Ch
Ett tecken.
_Elem
Elementtypen.
_Ostr
Ett basic_ostream objekt.
Str
En teckensträng.
_Tr
Karaktärsdrag.
val
Typ
Returvärde
Strömmen.
Anmärkningar
Klassen basic_ostream definierar också flera infogningsoperatorer. Mer information finns i basic_ostream::operator<<.
Mallfunktionen
template <class _Elem, class _Tr>
basic_ostream<Elem, _Tr>& operator<<(
basic_ostream<Elem, _Tr>& _ostr,
const Elem *str);
bestämmer längden N = traits_type::längd(str) för sekvensen som börjar på str och infogar sekvensen. Om N <_Ostr.bredd, infogar funktionen också en upprepning av _Ostr.width - N fyllningstecken. Upprepningen föregår sekvensen om (_Ostr.
flaggor & adjustfield != vänster. Annars följer upprepningen sekvensen. Funktionen returnerar _Ostr.
Mallfunktionen
template <class _Elem, class _Tr>
basic_ostream<Elem, _Tr>& operator<<(
basic_ostream<Elem, _Tr>& _Ostr,
Elem _Ch);
infogar elementet _Ch. Om 1 <_Ostr.widthinfogar funktionen också en upprepning av - 1 fyllningstecken _Ostr.width . Upprepningen föregår sekvensen om _Ostr.flags & adjustfield != left. Annars följer upprepningen sekvensen. Den returnerar _Ostr.
Mallfunktionen
template <class _Elem, class _Tr>
basic_ostream<Elem, _Tr>& operator<<(
basic_ostream<Elem, _Tr>& _Ostr,
const char *str);
beter sig på samma sätt som
template <class _Elem, class _Tr>
basic_ostream<Elem, _Tr>& operator<<(
basic_ostream<Elem, _Tr>& _Ostr,
const Elem *str);
förutom att varje element _Ch av sekvensen som börjar på str konverteras till ett objekt av typen Elem genom att anropa _Ostr.put(_Ostr.widen(_Ch)).
Mallfunktionen
template <class _Elem, class _Tr>
basic_ostream<Elem, _Tr>& operator<<(
basic_ostream<Elem, _Tr>& _Ostr,
char _Ch);
beter sig på samma sätt som
template <class _Elem, class _Tr>
basic_ostream<Elem, _Tr>& operator<<(
basic_ostream<Elem, _Tr>& _Ostr,
Elem _Ch);
förutom att _Ch konverteras till ett objekt av typen Elem genom att anropa _Ostr.put( _Ostr.widen( _Ch )).
Mallfunktionen
template <class _Tr>
basic_ostream<char, _Tr>& operator<<(
basic_ostream<char, _Tr>& _Ostr,
const char *str);
beter sig på samma sätt som
template <class _Elem, class _Tr>
basic_ostream<Elem, _Tr>& operator<<(
basic_ostream<Elem, _Tr>& _Ostr,
const Elem *str);
(Det behöver inte bredda elementen innan de infogas.)
Mallfunktionen
template <class _Tr>
basic_ostream<char, Tr>& operator<<(
basic_ostream<char, _Tr>& _Ostr,
char _Ch);
beter sig på samma sätt som
template <class _Elem, class _Tr>
basic_ostream<Elem, _Tr>& operator<<(
basic_ostream<Elem, _Tr>& _Ostr,
Elem _Ch);
(Den behöver inte bredda _Ch innan den infogas.)
Mallfunktionen
template <class _Tr>
basic_ostream<char, _Tr>& operator<<(
basic_ostream<char, _Tr>& _Ostr,
const signed char *str);
returnerar _Ostr << (const char *)str.
Mallfunktionen
template <class _Tr>
basic_ostream<char, _Tr>& operator<<(
basic_ostream<char, _Tr>& _Ostr,
signed char _Ch);
returnerar _Ostr << (char)_Ch.
Mallfunktionen:
template <class _Tr>
basic_ostream<char, _Tr>& operator<<(
basic_ostream<char, _Tr>& _Ostr,
const unsigned char *str);
returnerar _Ostr << (const char *)str.
Mallfunktionen:
template <class _Tr>
basic_ostream<char, _Tr>& operator<<(
basic_ostream<char, _Tr>& _Ostr,
unsigned char _Ch);
returnerar _Ostr << (char)_Ch.
Mallfunktionen:
template <class _Elem, class _Tr, class T>
basic_ostream<_Elem, _Tr>& operator<<(
basic_ostream<char, _Tr>&& _Ostr,
T val);
returnerar _Ostr << val (och konverterar en RValue-referens till _Ostr en lvalue i processen).
Exempel
Se flush för ett exempel med .operator<<