Sdílet prostřednictvím


operator<< (<ostream>)

Různé typy zápis do datového proudu.

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
    );

Parametry

  • _Ch
    Znak.

  • _Elem
    Typ prvku.

  • _Ostr
    Objekt basic_ostream.

  • _Str
    Řetězec znaků.

  • _Tr
    Vlastnosti znaku.

  • _Val
    Typ

Vrácená hodnota

Datový proud.

Poznámky

basic_ostream Třída definuje také několik vkládání operátorů.Další informace naleznete v tématu 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::Délka(_Str) na začátku sekvence na _Stra vloží sekvence.Pokud N <_Ostr.Šířka, potom funkce vloží také opakování _Ostr.width -N výplně znaků.Opakování posloupnosti předchází, pokud (_Ostr.příznaky&adjustfield != left.Opakování následuje v opačném pořadí.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.1 <_Ostr.width, potom funkce vloží také opakování _Ostr.width - 1 výplně znaků.Opakování posloupnosti předchází, pokud _Ostr.flags & adjustfield != left.Opakování následuje v opačném pořadí.Vrátí _Ostr.

Funkce šablony

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

se chová 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 ze začátku sekvence na _Str je převeden na objekt typu Elem voláním _Ostr.put(_Ostr.rozšířit(_Ch)).

Funkce šablony

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

se chová 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);

se chová stejně jako

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

(Nemá před jejich vložením, aby prvky.)

Funkce šablony

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

se chová stejně jako

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

(Nemá, aby _Ch ještě před jeho vložením.)

Funkce šablony

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

returns _Ostr<< (const char *)_Str.

Funkce šablony

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

returns _Ostr<< (char)_Ch.

Funkce šablony:

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

returns _Ostr<< (const char *)_Str.

Funkce šablony:

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

returns _Ostr<< (char)_Ch.

Funkce šablony:

template<class _Elem, class _Tr, class _Ty>
    basic_ostream<_Elem, _Tr>& operator<<(
        basic_ostream<char, _Tr>&& _Ostr,
        _Ty _Val
    );

Vrátí _Ostr << _Val (a převede RValue odkaz k _Ostr k lvalue v procesu).

Příklad

Viz vyprázdnění pro příklad použití operator<<.

Požadavky

Záhlaví:<ostream>

Obor názvů: std

Viz také

Referenční dokumentace

basic_ostream::operator<<

iostream – programování

iostreams – konvence