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

确定长度 = " traits_type::length(_Str) 序列开始在 _Str插入和序列。 如果跳过 <_Ostr.宽度,函数还再插入 _Ostr.width - N 填充字符重复。 重复前面序列,如果 (_Ostr。标志 &adjustfield ! = left。 否则,对于按照序列。 函数返回 _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 通过调用放置扩大(_Ch) _Ostr.(_Ostr.)。

函数模板

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 (将转换为的 _OstrRvalue 引用 到进程中的左值)。

示例

使用 **operator<<**的示例,请参见 刷新

要求

页眉: <ostream>

命名空间: std

请参见

参考

basic_ostream::operator<<

iostream 编程

iostreams 约定