Namespaces
Variants

std::ostreambuf_iterator

cppreference.net에서
 
 
반복자 라이브러리
반복자 컨셉
반복자 기본 요소들
알고리즘 컨셉 및 유틸리티
간접 호출 가능 컨셉
공통 알고리즘 요구 사항
(C++20)
(C++20)
(C++20)
유틸리티
(C++20)
반복자 어댑터
범위 접근
(C++11)(C++14)
(C++14)(C++14)  
(C++11)(C++14)
(C++14)(C++14)  
(C++17)(C++20)
(C++17)
(C++17)
 
 
헤더에 정의됨 <iterator>
template< class CharT, class Traits = std::char_traits<CharT> >
class ostreambuf_iterator
    : public std::iterator<std::output_iterator_tag, void, void, void, void>
(C++17까지)
template< class CharT, class Traits = std::char_traits<CharT> >
class ostreambuf_iterator;
(C++17부터)

std::ostreambuf_iterator 는 단일 패스 LegacyOutputIterator 로, 생성된 std::basic_streambuf 객체에 연속적인 문자를 씁니다. 실제 쓰기 연산은 반복자(역참조 여부와 관계없이)에 할당될 때 수행됩니다. std::ostreambuf_iterator를 증가시키는 것은 아무런 효과가 없습니다.

일반적인 구현에서 std::ostreambuf_iterator의 유일한 데이터 멤버는 연결된 std::basic_streambuf에 대한 포인터와 파일 끝 조건에 도달했는지 여부를 나타내는 부울 플래그입니다.

멤버 타입

멤버 타입 정의
iterator_category std:: output_iterator_tag
value_type void
difference_type

void

(C++20 이전)

std::ptrdiff_t

(C++20 이후)
pointer void
reference void
char_type CharT
traits_type Traits
streambuf_type std:: basic_streambuf < CharT, Traits >
ostream_type std:: basic_ostream < CharT, Traits >

멤버 타입 iterator_category , value_type , difference_type , pointer 및 reference 는 std:: iterator < std:: output_iterator_tag , void , void , void , void > 로부터 상속받아 얻어야 합니다.

(C++17 이전)

멤버 함수

새로운 ostreambuf_iterator 를 생성합니다
(public member function)
(destructor)
(implicitly declared)
ostreambuf_iterator 를 파괴합니다
(public member function)
문자를 연관된 출력 시퀀스에 기록합니다
(public member function)
no-op
(public member function)
no-op
(public member function)
출력 실패 여부를 검사합니다
(public member function)

예제

#include <algorithm>
#include <iostream>
#include <iterator>
#include <string>
int main()
{
    std::string s = "This is an example\n";
    std::copy(s.begin(), s.end(), std::ostreambuf_iterator<char>(std::cout));
}

출력:

This is an example

참고 항목

std::basic_streambuf 에서 읽어들이는 입력 반복자
(클래스 템플릿)
std::basic_ostream 에 기록하는 출력 반복자
(클래스 템플릿)