<ostream> 연산자

operator<<

operator<<

스트림에 다양한 형식을 씁니다.

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

매개 변수

_채널
단일 문자입니다.

_Elem
요소 형식입니다.

_Ostr
basic_ostream 개체입니다.

str
문자열입니다.

_Tr
문자 특성입니다.

val
형식

Return Value

스트림입니다.

설명

basic_ostream 클래스도 여러 가지 삽입 연산자를 정의합니다. 자세한 내용은 basic_ostream::operator<<를 참조하세요.

다음 템플릿 함수는

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

는 str에서 시작하는 시퀀스의 길이 N =traits_type:: length(str)를 결정하고 시퀀스를 삽입합니다. N <_Ostr.너비인 경우 함수는 - N 채우기 문자의 _Ostr.width 반복도 삽입합니다. 반복이 시퀀스 앞에 오는 경우(_Ostr) flags & adjustfield != left. 그렇지 않은 경우에는 반복이 시퀀스 뒤에 옵니다. 함수는 _Ostr 반환합니다.

다음 템플릿 함수는

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

_Ch 요소를 삽입합니다. 1 <_Ostr.width이면 함수는 -1 채우기 문자의 _Ostr.width 반복도 삽입합니다. _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);

단, str에서 시작하는 시퀀스의 각 요소 _Ch put(widen(_Ch_Ostr.))을 호출_Ostr.하여 형식 Elem 의 개체로 변환됩니다.

다음 템플릿 함수는

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 호출_Ostr.put( _Ostr.widen( _Ch ))하여 형식 Elem 의 개체로 변환됩니다.

다음 템플릿 함수는

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 T>
basic_ostream<_Elem, _Tr>& operator<<(
    basic_ostream<char, _Tr>&& _Ostr,
    T val);

_Ostr << val을 반환하고 RValue 참조_Ostr(프로세스의 lvalue)로 변환합니다.

예시

operator<<를 사용하는 방법의 예제를 보려면 flush를 참조하세요.

참고 항목

<ostream>