Namespaces
Variants

Standard library header <ostream>

From cppreference.net
Standard library headers

이 헤더는 Input/output 라이브러리의 일부입니다.

목차

클래스

주어진 추상 장치( std::basic_streambuf )를 감싸고
고수준 출력 인터페이스를 제공함
(클래스 템플릿)
std::ostream std:: basic_ostream < char >
(typedef)
std::wostream std:: basic_ostream < wchar_t >
(typedef)

함수

문자 데이터를 삽입하거나 rvalue 스트림에 삽입함
(함수 템플릿)
인수의 형식화된 표현을 출력함
(함수 템플릿)
인수의 형식화된 표현을 출력하고 ' \n ' 을 추가함
(함수 템플릿)
타입 삭제된 인수 표현을 사용하여
유니코드 인식 출력을 수행함
(함수)
타입 삭제된 인수 표현을 사용하여
문자 데이터를 출력함
(함수)
조작자
' \n ' 를 출력하고 출력 스트림을 플러시함
(함수 템플릿)
' \0 ' 를 출력함
(함수 템플릿)
출력 스트림을 플러시함
(함수 템플릿)
스트림의 basic_syncbuf 가 플러시 시
방출하는지 여부를 제어함
(함수 템플릿)
(C++20)
스트림을 플러시하고 basic_syncbuf
사용 중인 경우 내용을 방출함
(함수 템플릿)

시놉시스

namespace std {
  template<class CharT, class Traits = char_traits<CharT>>
    class basic_ostream;
  using ostream  = basic_ostream<char>;
  using wostream = basic_ostream<wchar_t>;
  template<class CharT, class Traits>
    basic_ostream<CharT, Traits>& endl(basic_ostream<CharT, Traits>& os);
  template<class CharT, class Traits>
    basic_ostream<CharT, Traits>& ends(basic_ostream<CharT, Traits>& os);
  template<class CharT, class Traits>
    basic_ostream<CharT, Traits>& flush(basic_ostream<CharT, Traits>& os);
  template<class CharT, class Traits>
    basic_ostream<CharT, Traits>& emit_on_flush(basic_ostream<CharT, Traits>& os);
  template<class CharT, class Traits>
    basic_ostream<CharT, Traits>& noemit_on_flush(basic_ostream<CharT, Traits>& os);
  template<class CharT, class Traits>
    basic_ostream<CharT, Traits>& flush_emit(basic_ostream<CharT, Traits>& os);
  template<class Ostream, class T>
    Ostream&& operator<<(Ostream&& os, const T& x);
  // 출력 함수들
  template<class... Args>
    void print(ostream& os, format_string<Args...> fmt, Args&&... args);
  template<class... Args>
    void println(ostream& os, format_string<Args...> fmt, Args&&... args);
  void println(ostream& os);
  void vprint_unicode(ostream& os, string_view fmt, format_args args);
  void vprint_nonunicode(ostream& os, string_view fmt, format_args args);
}

클래스 템플릿 std::basic_ostream

namespace std {
  template<class CharT, class Traits = char_traits<CharT>>
  class basic_ostream : virtual public basic_ios<CharT, Traits> {
  public:
    // types (inherited from basic_ios)
    using char_type   = CharT;
    using int_type    = typename Traits::int_type;
    using pos_type    = typename Traits::pos_type;
    using off_type    = typename Traits::off_type;
    using traits_type = Traits;
    // 생성자/소멸자
    explicit basic_ostream(basic_streambuf<char_type, Traits>* sb);
    virtual ~basic_ostream();
    // prefix/suffix
    class sentry;
    // 서식화된 출력
    basic_ostream& operator<<(basic_ostream& (*pf)(basic_ostream&));
    basic_ostream& operator<<(basic_ios<CharT, Traits>& (*pf)(basic_ios<CharT, Traits>&));
    basic_ostream& operator<<(ios_base& (*pf)(ios_base&));
    basic_ostream& operator<<(bool n);
    basic_ostream& operator<<(short n);
    basic_ostream& operator<<(unsigned short n);
    basic_ostream& operator<<(int n);
    basic_ostream& operator<<(unsigned int n);
    basic_ostream& operator<<(long n);
    basic_ostream& operator<<(unsigned long n);
    basic_ostream& operator<<(long long n);
    basic_ostream& operator<<(unsigned long long n);
    basic_ostream& operator<<(float f);
    basic_ostream& operator<<(double f);
    basic_ostream& operator<<(long double f);
    basic_ostream& operator<<(/*확장 부동 소수점 타입*/ f);
    basic_ostream& operator<<(const void* p);
    basic_ostream& operator<<(const volatile void* p);
    basic_ostream& operator<<(nullptr_t);
    basic_ostream& operator<<(basic_streambuf<char_type, Traits>* sb);
    // unformatted output
    basic_ostream& put(char_type c);
    basic_ostream& write(const char_type* s, streamsize n);
    basic_ostream& flush();
    // 탐색
    pos_type tellp();
    basic_ostream& seekp(pos_type);
    basic_ostream& seekp(off_type, ios_base::seekdir);
  protected:
    // 복사/이동 생성자
    basic_ostream(const basic_ostream&) = delete;
    basic_ostream(basic_ostream&& rhs);
    // assignment and swap
    basic_ostream& operator=(const basic_ostream&) = delete;
    basic_ostream& operator=(basic_ostream&& rhs);
    void swap(basic_ostream& rhs);
  };
  // 문자 삽입자
  template<class CharT, class Traits>
    basic_ostream<CharT, Traits>& operator<<(basic_ostream<CharT, Traits>&, CharT);
  template<class CharT, class Traits>
    basic_ostream<CharT, Traits>& operator<<(basic_ostream<CharT, Traits>&, char);
  template<class Traits>
    basic_ostream<char, Traits>& operator<<(basic_ostream<char, Traits>&, char);
  template<class Traits>
    basic_ostream<char, Traits>& operator<<(basic_ostream<char, Traits>&, signed char);
  template<class Traits>
    basic_ostream<char, Traits>& operator<<(basic_ostream<char, Traits>&, unsigned char);
  template<class Traits>
    basic_ostream<char, Traits>& operator<<(basic_ostream<char, Traits>&,
                                            wchar_t) = delete;
  template<class Traits>
    basic_ostream<char, Traits>& operator<<(basic_ostream<char, Traits>&,
                                            char8_t) = delete;
  template<class Traits>
    basic_ostream<char, Traits>& operator<<(basic_ostream<char, Traits>&,
                                            char16_t) = delete;
  template<class Traits>
    basic_ostream<char, Traits>& operator<<(basic_ostream<char, Traits>&,
                                            char32_t) = delete;
  template<class Traits>
    basic_ostream<wchar_t, Traits>&
      operator<<(basic_ostream<wchar_t, Traits>&, char8_t) = delete;
  template<class Traits>
    basic_ostream<wchar_t, Traits>&
      operator<<(basic_ostream<wchar_t, Traits>&, char16_t) = delete;
  template<class Traits>
    basic_ostream<wchar_t, Traits>&
      operator<<(basic_ostream<wchar_t, Traits>&, char32_t) = delete;
  template<class CharT, class Traits>
    basic_ostream<CharT, Traits>& operator<<(basic_ostream<CharT, Traits>&, const CharT*);
  template<class CharT, class Traits>
    basic_ostream<CharT, Traits>& operator<<(basic_ostream<CharT, Traits>&, const char*);
  template<class Traits>
    basic_ostream<char, Traits>& operator<<(basic_ostream<char, Traits>&, const char*);
  template<class Traits>
    basic_ostream<char, Traits>& operator<<(basic_ostream<char, Traits>&,
                                            const signed char*);
  template<class Traits>
    basic_ostream<char, Traits>& operator<<(basic_ostream<char, Traits>&,
                                            const unsigned char*);
  template<class Traits>
    basic_ostream<char, Traits>&
      operator<<(basic_ostream<char, Traits>&, const wchar_t*) = delete;
  template<class Traits>
    basic_ostream<char, Traits>&
      operator<<(basic_ostream<char, Traits>&, const char8_t*) = delete;
  template<class Traits>
    basic_ostream<char, Traits>&
      operator<<(basic_ostream<char, Traits>&, const char16_t*) = delete;
  template<class Traits>
    basic_ostream<char, Traits>&
      operator<<(basic_ostream<char, Traits>&, const char32_t*) = delete;
  template<class Traits>
    basic_ostream<wchar_t, Traits>&
      operator<<(basic_ostream<wchar_t, Traits>&, const char8_t*) = delete;
  template<class Traits>
    basic_ostream<wchar_t, Traits>&
      operator<<(basic_ostream<wchar_t, Traits>&, const char16_t*) = delete;
  template<class Traits>
    basic_ostream<wchar_t, Traits>&
      operator<<(basic_ostream<wchar_t, Traits>&, const char32_t*) = delete;
}

클래스 std::basic_ostream::sentry

namespace std {
  template<class CharT, class Traits>
  class basic_ostream<CharT, Traits>::sentry {
    bool ok_;       // 설명용 전용
  public:
    explicit sentry(basic_ostream& os);
    ~sentry();
    explicit operator bool() const { return ok_; }
    sentry(const sentry&) = delete;
    sentry& operator=(const sentry&) = delete;
  };
}