Namespaces
Variants

std:: ostreambuf_iterator

From cppreference.net
Iterator library
Iterator concepts
Iterator primitives
Algorithm concepts and utilities
Indirect callable concepts
Common algorithm requirements
(C++20)
(C++20)
(C++20)
Utilities
(C++20)
Iterator adaptors
Range access
(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 는 생성 시 지정된 std::basic_streambuf 객체에 연속적인 문자들을 기록하는 단일 패스 LegacyOutputIterator 입니다. 실제 기록 작업은 반복자(역참조 여부와 관계없이)에 할당이 수행될 때 이루어집니다. 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 에 기록하는 출력 반복자
(클래스 템플릿)