다음을 통해 공유


operator<<(<ostream>)

Writes various types to the 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 _Ty>
    basic_ostream<_Elem, _Tr>& operator<<(
        basic_ostream<_Elem, _Tr>&& _Ostr,
        Ty _Val
    );

매개 변수

  • _Ch
    문자입니다.

  • _Elem
    요소 형식입니다.

  • _Ostr
    basic_ostream 개체

  • _Str
    A character string.

  • _Tr
    Character traits.

  • _Val
    The type

반환 값

스트림입니다.

설명

The basic_ostream class also defines several insertion operators. 자세한 내용은 basic_ostream::operator<<을 참조하십시오.

The template function

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

determines the length N = traits_type::length(_Str) of the sequence beginning at _Str, and inserts the sequence. If N < _Ostr.width, then the function also inserts a repetition of _Ostr.width - N fill characters. The repetition precedes the sequence if (_Ostr.flags & adjustfield != left. Otherwise, the repetition follows the sequence. 함수는 _Ostr을 반환합니다.

The template function

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

inserts the element _Ch. If 1 < _Ostr.width, then the function also inserts a repetition of _Ostr.width - 1 fill characters. The repetition precedes the sequence if _Ostr.flags & adjustfield != left. Otherwise, the repetition follows the sequence. It returns _Ostr.

The template function

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

behaves the same as

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

except that each element _Ch of the sequence beginning at _Str is converted to an object of type Elem by calling _Ostr.put(_Ostr.widen(_Ch)).

The template function

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

behaves the same as

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

except that _Ch is converted to an object of type Elem by calling _Ostr.put(_Ostr.widen(_Ch)).

The template function

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

behaves the same as

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

(It does not have to widen the elements before inserting them.)

The template function

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

behaves the same as

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

(It does not have to widen _Ch before inserting it.)

The template function

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

returns _Ostr << (const char *)_Str.

The template function

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

returns _Ostr << (char)_Ch.

The template function:

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

returns _Ostr << (const char *)_Str.

The template function:

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

returns _Ostr << (char)_Ch.

The template function:

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

returns _Ostr << _Val (and converts a RValue Reference to _Ostr to an lvalue in the process).

예제

See flush for an example using operator<<.

요구 사항

Header: <ostream>

네임스페이스: std

참고 항목

참조

basic_ostream::operator<<

iostream 프로그래밍

iostreams 규칙