共用方式為


operator<< (<ostream>)

寫入至資料流各種型別。

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

參數

  • _Ch
    字元。

  • _Elem
    元素型別。

  • _Ostr
    basic_ostream 物件。

  • _Str
    字串。

  • _Tr
    配置特性。

  • _Val
    型別

傳回值

資料流。

備註

basic_ostream 類別也定義了幾種插入運算子。 如需詳細資訊,請參閱 basic_ostream::operator<<

樣板函式

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

判斷長度= N traits_type::長度(_Str) 序列開頭 _Str和插入這個序列。 如果< N _Ostr.寬度,函式只會插入 _Ostr.width - N 填補字元的重複。 逐一查看這個序列之前,如果 (_Ostr。旗標 _&;RYAN adjustfield ! = 以滑鼠左鍵。 否則,重複按照下列順序。 函式會傳回 _Ostr。

樣板函式

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

插入項目 _Ch。 如果 1 < _Ostr.width,函式只會插入 _Ostr.width 重複- 1 填補字元。 逐一查看這個序列之前,如果 _Ostr.flags & adjustfield != left。 否則,重複按照下列順序。 它會傳回 _Ostr。

樣板函式

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,
      const Elem *_Str);

,除了序列開頭的每個項目 _Ch 在 _Str 的會轉換成型別 Elem 物件上呼叫 _Ostr.(_Ostr.擴展(_Ch))。

樣板函式

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

行為相同。

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

但是, _Ch 會轉換為型別。 Elem 物件上呼叫 _Ostr.put(_Ostr.widen(_Ch))。

樣板函式

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

行為相同。

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

(它不一定要在插入之前予以擴充項目)。

樣板函式

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

行為相同。

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

(它不一定要在插入時擴展 _Ch )。

樣板函式

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

傳回 _Ostr << (const char *)_Str。

樣板函式

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

傳回 _Ostr << (char)_Ch。

樣板函式:

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

傳回 _Ostr << (const char *)_Str。

樣板函式:

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

傳回 _Ostr << (char)_Ch。

樣板函式:

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

傳回 _Ostr<<_Val (和轉換為 _Ostr 的 RValue 參考 至處理序中的左值)。

範例

使用 **operator<<**的範例,請參閱 清除

需求

標題: <ostream>

命名空間: std

請參閱

參考

basic_ostream::operator<<

iostream 程式設計

iostreams 慣例